Send form data to CGI script

Develop and Deploy Cross-Browser Web Apps .

Re: Send form data to CGI script

Postby joedarock » Thu Aug 10, 2017 3:21 pm

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: 159
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Postby joedarock » Thu Aug 10, 2017 3:24 pm

redacted
Last edited by joedarock on Thu Aug 10, 2017 6:50 pm, edited 1 time in total.
joedarock
 
Posts: 159
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Postby joedarock » Thu Aug 10, 2017 3:26 pm

redacted
Last edited by joedarock on Thu Aug 10, 2017 6:50 pm, edited 1 time in total.
joedarock
 
Posts: 159
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Postby joedarock » Thu Aug 10, 2017 5:03 pm

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?
joedarock
 
Posts: 159
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Postby support » Fri Aug 11, 2017 12:32 am

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>
support
 
Posts: 346
Joined: Sat Apr 27, 2013 9:22 am

Re: Send form data to CGI script

Postby joedarock » Fri Aug 11, 2017 10:11 am

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?
joedarock
 
Posts: 159
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Postby support » Fri Aug 11, 2017 11:53 am

Essentially, the response script is text, which can be recognized as SCRIPT by the browser.
support
 
Posts: 346
Joined: Sat Apr 27, 2013 9:22 am

Re: Send form data to CGI script

Postby joedarock » Fri Aug 11, 2017 1:14 pm

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?
joedarock
 
Posts: 159
Joined: Thu Nov 19, 2015 8:39 pm

Re: Send form data to CGI script

Postby support » Fri Aug 11, 2017 3:04 pm

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".
support
 
Posts: 346
Joined: Sat Apr 27, 2013 9:22 am

Re: Send form data to CGI script

Postby joedarock » Fri Aug 11, 2017 5:35 pm

This worked...thanks a lot!
joedarock
 
Posts: 159
Joined: Thu Nov 19, 2015 8:39 pm

Previous

Return to CrossUI for Web Apps

Who is online

Users browsing this forum: No registered users and 0 guests

cron