[development] autocomplete.js and http error 0

Roger Leigh rleigh at northcountry.com
Thu Aug 21 19:45:16 UTC 2008


The problem is not with the autocomplete php routine. The error is 
occurring in the javascript; it happens when the submit button is 
selected before the ajax routine is finished. You can repeat it by 
starting the autocomplete process (seeing the blue circle) and 
submitting immediately. Normally, it happens so fast that the process 
completes before the form is submitted, but I think this is a 
combination of bad server response, slow connection and large number of 
data entries to process.

I use firebug all the time, but I've never been much of a Javascript 
expert. It has something to do with code in jquery.js, and I can 
certainly look to that with an unpacked version, but I just hoped 
someone had encountered this already.

the error occurs on line 285 in the autocomplete.js, at the error alert:

    // Ajax GET request for autocompletion

    $.ajax({

      type: "GET",

      url: db.uri +'/'+ Drupal.encodeURIComponent(searchString),

      success: function (data) {

        // Parse back result

        var matches = Drupal.parseJson(data);

        if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {

          db.cache[searchString] = matches;

          // Verify if these are still the matches the user wants to see

          if (db.searchString == searchString) {

            db.owner.found(matches);

          }

          db.owner.setStatus('found');

        }

      },

      error: function (xmlhttp) {

        alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ db.uri);

      }

-Roger


Dropcube wrote:
> Firebug can help you to debug, you can see the headers and output of 
> the Ajax requests.
> http://getfirebug.com/
>
> Charlie Gordon wrote:
>> Roger Leigh wrote:
>>> Any ideas?
>>
>> Perhaps try figuring out why an "http error 0" occurred, rather than 
>> suppressing the message in autocomplete.js. E.g. go to the 
>> autocomplete path specified - do you get the proper headers and json?
>>
>> -Charlie
>


More information about the development mailing list