Drupal 7 Autocomplete - ajax

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: htps://MYSITE/index.php?q=user/autocomplete
StatusText:
ResponseText:
ReadyState: 4
I get that error when I try to type in the autocomplete box that is installed from core drupal.
I've read up on documentation on patching these files https://www.drupal.org/node/1232416 and did so.
In my console I get an error of :
XMLHttpRequest cannot load htps://SITE_B. Redirect from htps://ANOTHERSITE' to 'htps://SITE_B' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'htps://MYSITE' is therefore not allowed access.
So I researched CORS and added htp://stackoverflow.com/questions/13421463/htaccess-access-control-allow-origin
suggestion about .htaccess but to no avail.
I'm running drupal 7.51 on Dev Desktop 2 on a localhost. As well I have it running live, but want to fix it locally first. Any suggestions will help, I've research for hours now.

After countless hours and cold showers, I found out my answer. There was a bad php script in one of the nodes that used Drupal_goto(). That is how I got XMLHttpRequest. I followed https://drupal.stackexchange.com/questions/22825/how-to-find-bad-php-node-that-makes-search-cron-fail to find out where my php script failed me at.

Related

AJAX request terminated abnormally with select photo uploads in Drupal

I'm busy fixing an issue on a site a friend runs for her work. I have worked on this site before, and this is the only Drupal site I have ever worked on, so I am somewhat of a newbie to Drupal. The original dev decided they no longer wanted to maintain it quite some time ago and kind of disappeared shortly after.
The issue:- Most photos upload fine however some cause the following error:
An AJAX HTTP request terminated abnormally. Debugging information follows.
Path: /?q=file/ajax/field_accom_image/und/form--5hp1P7pzFdShaND24CsiI7QNe3f9bApEq9Gu78bRZg
StatusText: n/a
ResponseText: Bad Request Your browser sent a request that this server could not understand. Apache Server at REAL_URL_REDACTED Port 80
ReadyState: undefined
I have found "An AJAX HTTP request terminated abnormally" errors on StackOverflow and the Drupal site, however, none of them had a "ResponseText" of "Bad Request" and a "ReadyState" of "undefined" simultaneously.
This didn't stop me from trying troubleshooting from those answers, such as setting the $base_url variable in settings.php, checking and changing permissions on the server, disable the overlay feature for the admin settings, compressing the image to a smaller file size, dropping the image resolution, removing all possible metadata from the image, checking the upload max file size in the php config.
Drupal version is 7.59

Service worker Failed to load resource: net::ERR_UNSAFE_REDIRECT

would you please tell me what i did wrong with my service worker installation, i have those errors appear in chrome console (see the image-1).
The script resource is behind a redirect, which is disallowed. service-worker.js:1
Failed to load resource: net::ERR_UNSAFE_REDIRECT https://harampress.com/post/45/service-worker.js
i use Laravel framework in backend if that could help
just to know that my service-worker.js is in the root of the website, works fine on home page no errors on chrome console, but the moment i try to navigate to a post for example, those two errors appears (see image-2).
knowing that i use sw-precache and sw-toolbox, i generate the service worker useing sw-precache with gulp.
image-1
image-2
see the solutions here on github discussion
the message from the discussion in github that actually answered to my problem :
What #wanderview means is that when you do
navigator.serviceWorker.register('/sw.js')
The actual requesting URL is the sw.js located in the root
but when you do
navigator.serviceWorker.register('sw.js')
This is actually a Relative URL so what you actually request might be /post/blah/sw.js and your server might treat it as 404 and do some redirect.

AJAX error, Drupal 7

I got an AJAX error while running Drupal 7.
"An AJAX error occured.
HTTP result code: 500
Debugging information follows:
Path: system/AJAX
StatusText: error
Response text:"
There is no response text. I have looked everywhere and tried a couple of things, but nothing works. Anyone have an idea on how to fix it?
Thanks
Check your watchdog table, if nothing there check the php error log.
Also use Firebug's console to check what is returned after the ajax request for any clues.
Can also try disabling third party modules one at a time to find out what is causing the error.

angularjs looking for files on localhost after grunt-distribution

i'm working on a project with angular and grunt. before "grunting" angular reads the local files, but after "grunting" my index.html-file doesn't show anything. the tool "console" in chrome show me this error message:
"XMLHttpRequest cannot load file:///Users/userxx/Dropbox/Produktion/_resources/workspaces/userxx.html5/taleshipkiosk/_temp/repository/taleshipkiosk/dist/views/kiosk.html. Origin null is not allowed by Access-Control-Allow-Origin. index.html:1"
its seems that angular is still looking for one local file called "kiosk.html". but how can that be? this file (kiosk.html) is already in my dist-folder.
any ideas how to fix it?
thx
This doesn't look like it's really related to grunt at all. It seems like you're trying to make an XHR request that Chrome is regarding as cross-origin. You should try looking for answers regarding "origin null not allowed"
example: https://stackoverflow.com/a/4752452/628699

Why is AJAX returning HTTP status code 0?

For some reason, while using AJAX (with my dashcode developed application) the browser just stops uploading and returns status codes of 0. Why does this happen?
Another case:
It could be possible to get a status code of 0 if you have sent an AJAX call and a refresh of the browser was triggered before getting the AJAX response. The AJAX call will be cancelled and you will get this status.
In my experience, you'll see a status of 0 when:
doing cross-site scripting (where access is denied)
requesting a URL that is unreachable (typo, DNS issues, etc)
the request is otherwise intercepted (check your ad blocker)
as above, if the request is interrupted (browser navigates away from the page)
Same problem here when using <button onclick="">submit</button>. Then solved by using <input type="button" onclick="">
Status code 0 means the requested url is not reachable. By changing http://something/something to https://something/something worked for me. IE throwns an error saying "permission denied" when the status code is 0, other browsers dont.
It is important to note, that ajax calls can fail even within a session which is defined by a cookie with a certain domain prefixed with www. When you then call your php script e.g. without the www. prefix in the url, the call will fail and viceversa, too.
Because this shows up when you google ajax status 0 I wanted to leave some tip that just took me hours of wasted time... I was using ajax to call a PHP service which happened to be Phil's REST_Controller for Codeigniter (not sure if this has anything to do with it or not) and kept getting status 0, readystate 0 and it was driving me nuts. I was debugging it and noticed when I would echo and return instead of exit the message I'd get a success. Finally I turned debugging off and tried and it worked. Seems the xDebug debugger with PHP was somehow modifying the response. If your using a PHP debugger try turning it off to see if that helps.
I found another case where jquery gives you status code 0 -- if for some reason XMLHttpRequest is not defined, you'll get this error.
Obviously this won't normally happen on the web, but a bug in a nightly firefox build caused this to crop up in an add-on I was writing. :)
This article helped me. I was submitting form via AJAX and forgotten to use return false (after my ajax request) which led to classic form submission but strangely it was not completed.
"Accidental" form submission was exactly the problem I was having. I just removed the FORM tags altogether and that seems to fix the problem. Thank you, everybody!
I had the same problem, and it was related to XSS (cross site scripting) block by the browser. I managed to make it work using a server.
Take a look at: http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/282972/why-am-i-getting-xmlhttprequest.status0
We had similar problem - status code 0 on jquery ajax call - and it took us whole day to diagnose it. Since no one had mentioned this reason yet, I thought I'll share.
In our case the problem was HTTP server crash. Some bug in PHP was blowing Apache, so on client end it looked like this:
mirek#toccata:~$ telnet our.server.com 80
Trying 180.153.xxx.xxx...
Connected to our.server.com.
Escape character is '^]'.
GET /test.php HTTP/1.0
Host: our.server.com
Connection closed by foreign host.
mirek#toccata:~$
where test.php contained the crashing code.
No data returned from the server (not even headers) => ajax call was aborted with status 0.
In my case, it was caused by running my django server under http://127.0.0.1:8000/ but sending the ajax call to http://localhost:8000/. Even though you would expect them to map to the same address, they don't so make sure you're not sending your requests to localhost.
In our case, the page link was changed from https to http. Even though the users were logged in, they were prevented from loading with AJAX.
In my case, setting url: '' in ajax settings would result in a status code 0 in ie8.. It seems ie just doesn't tolerate such a setting.
For me, the problem was caused by the hosting company (Godaddy) treating POST operations which had substantial response data (anything more than tens of kilobytes) as some sort of security threat. If more than 6 of these occurred in one minute, the host refused to execute the PHP code that responded to the POST request during the next minute. I'm not entirely sure what the host did instead, but I did see, with tcpdump, a TCP reset packet coming as the response to a POST request from the browser. This caused the http status code returned in a jqXHR object to be 0.
Changing the operations from POST to GET fixed the problem. It's not clear why Godaddy impose this limit, but changing the code was easier than changing the host.
I think I know what may cause this error.
In google chrome there is an in-built feature to prevent ddos attacks for google chrome extensions.
When ajax requests continuously return 500+ status errors, it starts to throttle the requests.
Hence it is possible to receive status 0 on following requests.
In an attempt to win the prize for most dumbest reason for the problem described.
Forgetting to call
xmlhttp.send(); //yes, you need this pivotal line!
Yes, I was still getting status returns of zero from the 'open' call.
In my case, I was getting this but only on Safari Mobile. The problem is that I was using the full URL (http://example.com/whatever.php) instead of the relative one (whatever.php). This doesn't make any sense though, it can't be a XSS issue because my site is hosted at http://example.com. I guess Safari looks at the http part and automatically flags it as an insecure request without inspecting the rest of the URL.
In my troubleshooting, I found this AJAX xmlhttpRequest.status == 0 could mean the client call had NOT reached the server yet, but failed due to issue on the client side. If the response was from server, then the status must be either those 1xx/2xx/3xx/4xx/5xx HTTP Response code. Henceforth, the troubleshooting shall focus on the CLIENT issue, and could be internet network connection down or one of those described by #Langdon above.
In my case, I was making a Firefox Add-on and forgot to add the permission for the url/domain I was trying to ajax, hope this saves someone a lot of time.
Observe the browser Console while making the request, if you are seeing "The Same Origin Policy disallows reading the remote resource at http ajax..... reason: cors header ‘access-control-allow-origin’ missing" then you need to add "Access-Control-Allow-Origin" in response header. exa: in java you can set this like response.setHeader("Access-Control-Allow-Origin", "*") where response is HttpServletResponse.

Resources