tags:

views:

1249

answers:

2

There is an undefined error due Ajax request in jQuery. But it works locally. Error referencing in jquery1.3.2.js @ 3633 line

    xhr.send(s.data);

My code is:

    $.ajax({
 type: "POST",
 url: 'index.php',
 data: "action=showpath&type=images&path=&default=1",
 cache: false,
 dataType: "html",
 success: function(data){
  $('#addr').html(data);
 },
    error:function (xhr, ajaxOptions, thrownError){
            alert(xhr.status);
            alert(thrownError);
    }       
});

alerts in code shows me (0, 'undefined');

What i am doing wrong?

A: 

Couldn't tell ya offhand, but it is probably something on the server-side in index.php. Best way to tell is to look at the raw response using a http debugger. The Firebug firefox extension has a pretty good one, and fidder2 is a beefy option.

Wyatt Barnett
I have tested it with firebug. There is erroneous response displyed, but it's own status is 200 - OK. Ajax request returns ajaxError without explanation.
RayZ
I have found same problem description athttp://www.mail-archive.com/[email protected]/msg65106.htmlBut still no solution.
RayZ
+2  A: 

This could be happening if your ajax request is getting canceled before it completes. jQuery throws the error event when the user navigates away from the page either by refreshing, clicking a link, or changing the URL in the browser. You can detect these types of errors by by implementing an error handler for the ajax call, and inspecting the xmlHttpRequest object:

$.ajax({
    /* ajax options omitted */
    error: function (xmlHttpRequest, textStatus, errorThrown) {
         if(xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0) 
              return;  // it's not really an error
         else
              // Do normal error handling
});
colbeerhey