Question

  • I have been using jquery 1.3.2, and I upgraded to 1.9.1 What happens is that the ajax request that was reaching success, is reaching error now. I don't understand why, the status is 200, and the state is 4. Which means nothing wrong with the request. But why it is reaching the error?

I made a work around as below but i don't like it. I would like to understand why it happened.I'm also afraid to have more problems like that.

 $.ajax({
    type: "POST",
    url: "test.cgi",
    data: form_data,
    beforeSend: function(){
        $("#"+type+"_div").html("<span class='LabelRed12'>Loading , please wait..</span><br/>");
    },
    complete: function(){

    },
    success: function(html){
        $("#"+type +"_div").html(html);

    },
    error:function(xhr,err){
         if (xhr.readyState == 4) {
           if (xhr.status == 200) {
                $("#"+type +"_div").html(xhr.responseText);
           } else
             alert("status is " + request.status);
         }
    }
    });
Était-ce utile?

La solution

You problem might be that you don't specify dataType for your ajax request, try adding this :

dataType: 'json'

Autres conseils

you should use jquery migrate plugin when you move from lover version to higher version. Check the jquery site and get the migrate jquery api. This will solve your issue

Refer : jquery.com/download/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top