0

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 Answers 2

2

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!)

Sign up to request clarification or add additional context in comments.

3 Comments

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.
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
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.