autocomplete.js and http error 0
I'm working with an autocomplete text field in a module, and some users were getting an alert error, "An HTTP error 0 occured". I was finally able to reproduce this error, not only on my form but on a standard CCK form as well; if you click the form submit button while the autocomplete is retrieving entries (the 'blue wheel' is present), it triggers the error. Surprisingly, I couldn't find a lot of info on a drupal search, though I did see some related reports in other projects. Looking at the autocomplete.js file, I see the alert at line 285. Obviously I can change it here, but always hate to hack the core. Any ideas? Regards, Roger
Quoting Roger Leigh <rleigh@northcountry.com>:
Any ideas?
File an issue and supply a patch file for the fix. Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
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
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
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
participants (4)
-
Charlie Gordon -
Dropcube -
Earnie Boyd -
Roger Leigh