Send form data to CGI script

Develop and Deploy Cross-Browser Web Apps .
joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

Sorry for my scatterbrained mistake...my posting above is the working client HTML form , not the server script. Basically, I have to reproduce the functionality of the HTML code.

joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

redacted
Last edited by joedarock on Thu Aug 10, 2017 6:50 pm, edited 1 time in total.

joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

redacted
Last edited by joedarock on Thu Aug 10, 2017 6:50 pm, edited 1 time in total.

joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

I got it working...the last remaining problem was in my server script...dooooh!

How can I get status information or the server script's 'Print' output?

support
Posts: 356
Joined: Sat Apr 27, 2013 9:22 am

Re: Send form data to CGI script

Post by support »

I didn't familiar with CGI script, you can download other 'backend'(php/c#/Node.js/java) demo code from here.

http://www.crossui.com/download.html

Basically, you need to response some script in your CGI script, like
html code
<script type='text' id='json'>{"parentDomain":"http:\/\/localhost","data":[{"p1":"client_set","p2":"server_set","time":"2017-08-11 00:30:35","rand":"12-30-358y2zwikhzt5yqqt0s"}]}</script>
<script type='text/javascript'>
    parent.postMessage(document.getElementById('json').innerHTML,'http://localhost'.replace( /([^:]+:\/\/[^\/]+).*/, '$1'));
</script>

joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

Unvortunately, the server is a small embedded device on a closed industrial network and installing another scripting engine isn't possible. My server script can "Print" either plain text or HTML to the client's browser. Can one of those be used to generate a response and how can the client javascript receive it?

support
Posts: 356
Joined: Sat Apr 27, 2013 9:22 am

Re: Send form data to CGI script

Post by support »

Essentially, the response script is text, which can be recognized as SCRIPT by the browser.

joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

Let me be more specific:
in my CrossUI app, I have a pane with the file combo and submit button. This sends the selected file. That much works. How can I get feedback from the server script to appear in the pane?

support
Posts: 356
Joined: Sat Apr 27, 2013 9:22 am

Re: Send form data to CGI script

Post by support »

1. When you uploaded finish, return html

<script type='text' id='json'>{"data":{"message":"ok"}}</script>
<script type='text/javascript'>
parent.postMessage(document.getElementById('json').innerHTML,'*');
</script>

2. If your xui code is:
xui.request(xxxxxx,{file:file},function(rsp){
xui.alert(rsp.data.message);
},function(errMsg){
xui.alert(errMsg)
}).start();

That will alert message "ok".

joedarock
Posts: 169
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Post by joedarock »

This worked...thanks a lot!

Post Reply