Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have an autocomplete search box on the site I am working with currently. The autocomplete works fine as I type text in the box. However when I interrupt the autocomplete process by pressing the search button a javascript alert pops up with the message "An HTTP error 0 occurred".
There is a function to cancel the autocomplete request. Wouldn't it be possible to cancel the autocomplete request when the form is submitted?
Comments
Comment #1
mcsolas CreditAttribution: mcsolas commented+1. Having same issue running the same version.
Searches are not giving me much info yet. there are a few references to this in the drupal 5 issue bin... but doesn't seem to be any answers in there... still searching.
Comment #2
anoopjohn CreditAttribution: anoopjohn commentedIf somebody could give me a pointer as to how to do this I can put some effort into fixing this error.
Comment #3
eikes CreditAttribution: eikes commentedI had the same problem, and I really don't see how that alert is helpful to the normal user, so I just removed the alert:
opened misc/autocomplete.js and put two forward slashes before line 285 (Drupal 6.14), like this:
In HEAD it's a little further down, 292: http://drupalcode.org/viewvc/drupal/drupal/misc/autocomplete.js?view=markup
Beware though, when developing new autocomplete callbacks you will not be told anymore if you get 404s or the likes. As an alternative you can log it to the js-console:
console.log(Drupal.ahahError(xmlhttp, db.uri));
I think it would be best though if there was a way to log this to the drupal watchdog table and not use the javascript "alert", because it blocks the whole user experience. Obviously this would require making another AJAX request, but that would be ok, if we weren't waiting for an answer. so maybe http://drupal.org/project/jserrorlog should be ported to D6 and changed accordingly. Then maybe even overwrite the whole alert message:
window.alert = jsErrorLogger.onError;
Also I don't see how it is an error at all, when I type faster than the request is made, it's really terrible to keep me from doing that by throwing this ugly alert window on my screen.
I could go on... but you're basically set if you just remove the alert line.
Comment #4
Fabianx CreditAttribution: Fabianx commentedHi,
The bug ist still there in 6.16. I also changed alert to console.log.
I think this should be fixed as that is really annoying to the user.
Best Wishes,
Fabian (LionsAd)
Comment #5
mcsolas CreditAttribution: mcsolas commentedYeah, I still have this pop up on occasion.. especially on the mac using firefox. Still not sure how to resolve this in any effective manner.
Comment #6
alienzed CreditAttribution: alienzed commentedsee #3 for solution
you need to comment out that line in both misc/autocomplete.js AND sites/all/modules/finder/modules/finder-autocomplete.js
Comment #7
hefox CreditAttribution: hefox commentedThere is no need to modify core for this; javascript functions are overrideable.
Create or add to a js function to something that'd run after autocomplete, like in your theme layer
Add
However, I agree that this error is only really useful for the developer.
edit: Updating code snippit
Comment #8
wanjee CreditAttribution: wanjee commentedHi,
Same error for me and I can repeat it easily.
I have a custom autocomplete callback that is used by a form element, add some delay in this callback if the autocomplete result appears too fast. Using Firefox, Safari or Chrome I get the error as soon as I submit the field by pressing enter before the autocomplete suggestion appears (while the blue working indicator is spinning in the field).
I think the error is logical but the alert is far too violent for lambda users.
I will apply solution of #7 but it would be great to get a more silent error in further releases, at least for user with less privileges.
Thanks,
Wanjee
Comment #9
vasikesubscribe
Comment #10
FiNeX CreditAttribution: FiNeX commentedsubscribe
Comment #11
Chi CreditAttribution: Chi commentedsubscribe
Comment #12
BigMike CreditAttribution: BigMike commentedsubscribed
Comment #13
crifi CreditAttribution: crifi commentedThis problem is maybe caused by a wrong configuration of $base_url and should be prevented by inserting a warning message to the requirements system. Therefore I created a new issue #1046682: Install/Update process fails if $base_url is set to a wrong URL. Please close this bug as a duplicate, if this solves your issue. Thanks!
Comment #14
Jztinfinity CreditAttribution: Jztinfinity commentedI had a similar experience and here's the solution I hit.
So I had modified my autocomplete to add an autocomplete_select callback per - http://drupal.org/node/365241
I then added a callback to an autocomplete input that caused form.submit
Two issues:
1. based on the patch used (and rightfully given possible utility) the 'autocomplete_select' event fires onsubmit, which means adding a submit to the callback created an infinite loop. While jquery.one should have fixed the issue, for some reason it didn't, and so I went with a different approach, I attached to the form a class "submitting" and then added the condition that it not submit if that class was present on the form. Problem solved, but now the form wouldn't submit based on autocomplete.js' code for Drupal.autocompleteSubmit.
2. to solve the Drupal.autocompleteSubmit issue I ran $("#autocomplete").remove() before submitting, which solved the problem nicely.
For some reason and I'm still not sure why, the confluence of these two issues caused the "HTTP error 0 occurred" alert, and apparently fixing those issues caused it to be fixed. My theory? Because I'm removing out $("#autocomplete") it's killing off any possible new autocomplete attempts, which helps to avoid autocomplete interruption via form submit.
I hope this helps, although I'm not sure it will.
My 2 cents on Drupal.ahahError, Drupal should have a mechanism for switching on and off a "dev" variable which is accessible via js (directly through dynamic js, or alternatively via a body class, a meta tag, etc.). Thus one could then enable behavior of javascript useful for debugging but that should not be seen in production.
Comment #15
AdrianB CreditAttribution: AdrianB commentedThanks to crifi in #13. I had $base_url set to www.example.com but was using the site without www (only example.com), when I changed to www.example.com in my browser the error went away.
Comment #16
blaiz CreditAttribution: blaiz commentedSubscribe
Comment #17
Christian Le Fournis CreditAttribution: Christian Le Fournis commentedSubscribe
Comment #18
Naiya CreditAttribution: Naiya commentedSubscribe
for now i have added
in autocomplete.js
Greetings
Comment #19
nod_More info here: https://drupal.org/node/1232416#comment-5526162
and about what #14 is talking about : #1419652: JavaScript logging and error reporting.
Comment #20
nod_see above