jQuery AJAX timeout undefined

By | January 12, 2018
Questions:

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?

Edit: Code snippet moved from the comments to the question

$.ajax({ 
  type: "GET", 
  dataType: 'json', 
  url: PHPServiceProxy, 
  timeout: 5000, 
  success: function(reply) { } // note: original code snippet provided was missing a comma here.
  error: function (xhr, textStatus, errorThrown) { } 
});
Answers:

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

    } 
});

Leave a Reply

Your email address will not be published. Required fields are marked *