4

I'm trying to catch Ajax timeout error with jQuery 1.4.2, but none of tutorial I found work. In Firebug, when timeout error fires. I see:

uncaught exception: [object Object].

Please help me handle Ajax timeout. Here's my JS code:

$.ajax({
    type:"POST",
    url:"/data/add/",
    data:
    {
    "date":$("input#date").val();
    },
    dataType:"json",
    timeout:2000,
    success: function(response) {
    },
    error: function () {
        alert('Server error');
    }
});
1
  • You have an errant semi-colon in your data option. See my answer below. Commented Aug 22, 2010 at 3:35

2 Answers 2

5

I tested this out, and if you remove the ; from your $("input#date").val() statement, it should work.

$.ajax({
    type:"POST",
    url:"/data/add/",
    data:
    {
    "date":$("input#date").val()
    },
    dataType:"json",
    timeout:2000,
    success: function(response) {
    },
    error: function () {
        alert('Server error');
    }
});
Sign up to request clarification or add additional context in comments.

Comments

1

something went wrong again, and i got googled this f*****g bug http://dev.jquery.com/ticket/6173 ! here is the spike:

success: function(response, textStatus, xhr) {
    if (!xhr.status) {
        alert("ERROR!!!!");
    }
    else {
        // elided
    }

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.