Search code examples
jqueryversions

Weird things happens when upgrading from jquery 1.3.2 to 1.9.1


  • 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);
         }
    }
    });

Solution

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

    dataType: 'json'