tags:

views:

25

answers:

1

On my form onbutton submit following events takes place:

1) CGI is called which uploads the file

2) Javascript/Ajax function is called which opens a request for another CGI and is supposed to receive updated values from there. However, it seems that the CGI with which Ajax is communicating is not responding to Ajax requests.

My question is that is it possible to run two CGIs simultaneously?

A: 

Yes, there is no reason that you cannot run 2 cgi's simultaneously , on the other hand there are countless ways to make it troublesome with my personal favorite being the use of stateful session beans.

Seriously, I think it is probably caused by the fact that by pressing the submit button you are actually going to another page which destroys the AJAX/Javascript environment so there is nothing left anymore to react on the 2nd CGI.

Now this is a guess, because nowadays, so many different things can happen when you press a button, but I think it is worth checking this out.

Peter Tillemans
Yes, something this kind is happening. However, I would like to add here, Ajax receives the LAST response from CGI not the intermediate. For, some other CGI it receives intermediate response as well, but in any case its not ALWAYS as it should receive.My CGI with which Ajax communicates is using a linux system() command to o/p the data. Any idea how should I proceed further?
Punit
GET,PUT or POST a request and you get a response. In order to do something with the response the script must still be there, or the http server will kill the CGI script when the connection gets broken.You might consider replacing the submit button by a normal button and submit the form when you know your AJAX request is done. Or alternatively using the onClick to wait for the AJAX script to finish
Peter Tillemans
Well the Ajax gets a responseText from 2nd CGI so Ajax,CGI1 and CGI2 work simultaneously. Can not wait for AJAX script to finish. Something wrong with CGI2. Ajax is working properly, it is only that it doesn't get any response from CGI2.
Punit
Can't you run CGI2 independently using wget or curl or similar tool. Easier to see what's happening and debug the CGI2 script. Do both CGI scripts share resources i.e. go to the same files or databases? You might have a lock issue.
Peter Tillemans
Well, I can not use any other tools due to limited resources.Both CGIs run independently, so there is no lock issue. One CGI loads the file and the other CGI is running a Linux system command: system("CMD") to output the size of the directory.
Punit