views:

901

answers:

3

Hello,

I have a jquery HTML page which loads a form.

The form has a bunch of settings, but eventually the form gets submitted using a post command (see below) which returns an HTML page built by a script running on the server.

This works fine, except when the script runs longer than 5 minutes. The post command just returns nothing.

I tried using the timeout command in the high level page as follows:

$.ajaxSetup({cache: false, timeout: 18000000 }) ;

But this does not seem to work. Does anyone have a suggestion?

Here is the post command:

$.post('/cgi-bin/tw_lookup_3.cgi', lookupData, function(data){

         var page = $(data).find('input[name=result_dir]').val();
         $('#results').load( page + "/TW_LOOKUP_RESULTS.html");


         $('#SubmitQuery').attr('disabled',false);
         $('#SubmitQuery').val('Submit Query');
         $('#SubmitQuery').css('backgroundColor','');
         $('#SubmitQuery').css('color','');
},"html");
+2  A: 

Is it possible that the timeout occurs on the server and it's just returning an error? Set an error handling function and determine if that is being called. Handling errors should be a standard practice anyway in this case, in particular if you are expecting it to take exceptionally long (like 5 minutes!)

altCognito
Thanks for the comment.Well this is my first interactive application with Jquery, so it is part of why I am having trouble, just learning the process. And yes I should have some error handling, but as I am new at this, it is another step in the process. So I think I need to use the ajax method rather than the post method so I can control the timeout and add error handling.The code works fine when the cgi script finishes within 5 minutes.The cgi script runs another script on unix and after that completes the cgi script builds an HTML to send back to jquery page.I will update later
No problem, and just to be clear, I wasn't trying to be pedantic or suggest that you were being lazy by not following some sort of best practice, I just saw it as a possible helpful way to see into the process.
altCognito
No problem and no offense taken. I was trying to get a small project done and was close when I saw this problem.As I have found as a programmer cutting corners (no error handling) always comes back. In this case, it will help me understand more and get further ahead. Just another step on the learning curve.I'll update on my progress. Thanks,Stev e
A: 

All I worked with a coworker on this and we found that the issue is indeed the server and not the webpage where I was trying to set the timeout.

I hope this helps someone in the future and thanks for those that replied.

Steve

A: 

I am facing the same issue. Is it the web server that's timing out? Any suggestions on how to resolve it when the server takes longer than 5 minutes to respond? It works fine when the server responds back in under 5 minutes.

bvdev