views:

171

answers:

2

I was trying out example JQuery examples and to my surprise, I got an error state for an AJAX call mentioning that timeout isn't defined. When I removed timeout attribute, it worked fine. I downloaded JQuery few days back, so I am pretty sure it's not a version problem.

I was trying with Firefox(3.6.8) and not any other browser.

Why would this occur?

A: 

Ajax requests are time-limited, so errors can be caught and handled to provide a better user experience. Request timeouts are usually either left at their default or set as a global default using $.ajaxSetup() rather than being overridden for specific requests with the timeout option.

Sarfraz
+2  A: 

The timeout property has been present in jQuery for a long time so I don't think that your problem is related to it. Maybe you have a syntax error in your code. This should work:

$.ajax({ 
    type: 'GET', 
    dataType: 'json', 
    url: PHPServiceProxy, 
    timeout: 5000, 
    success: function(reply) { 

    },
    error: function (xhr, textStatus, errorThrown) { 

    } 
});
Darin Dimitrov
I have tried it couple of times and I too am surprised that it wasn't working. It was happening at my office PC. Well let me try that now and see if things are working.
Gunner
Looks to work here at my PC. I guess you are right, must have missed out something.
Gunner