How to get response status code from jQuery.ajax?

In the following code, all I am trying to do is to get the HTTP response code from a jQuery.ajax call. Then, if the code is 301 (Moved Permanently), display the ‘Location’ response header: <?xml version=”1.0″ encoding=”utf-8″?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”> <head> <title>jQuery 301 Trial</title> <script src=”http://code.jquery.com/jquery-1.5.1.min.js”></script> … Read more

jQuery $.ajax(), $.post sending “OPTIONS” as REQUEST_METHOD in Firefox

Having trouble with what I thought was a relatively simple jQuery plugin… The plugin should fetch data from a php script via ajax to add options to a <select>. The ajax request is pretty generic: $.ajax({ url: o.url, type: ‘post’, contentType: “application/x-www-form-urlencoded”, data: ‘{“method”:”getStates”, “program”:”EXPLORE”}’, success: function (data, status) { console.log(“Success!!”); console.log(data); console.log(status); }, error: … Read more

CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

I have a setup involving Frontend server (Node.js, domain: localhost:3000) <—> Backend (Django, Ajax, domain: localhost:8000) Browser <– webapp <– Node.js (Serve the app) Browser (webapp) –> Ajax –> Django(Serve ajax POST requests) Now, my problem here is with CORS setup which the webapp uses to make Ajax calls to the backend server. In chrome, … Read more

WebSockets protocol vs HTTP

There are many blogs and discussions about WebSocket and HTTP, and many developers and sites strongly advocate WebSockets, but I still can not understand why. For example (arguments of WebSocket lovers): HTML5 Web Sockets represents the next evolution of web communications—a full-duplex, bidirectional communications channel that operates through a single socket over the Web. – … Read more

Getting “net::ERR_BLOCKED_BY_CLIENT” error on some AJAX calls

Recently I’ve realised that, some adblocker extensions (such as adBlocker plus) block some Ajax calls. I get that error on the console: GET http://localhost/prj/conn.php?q=users/list/ net::ERR_BLOCKED_BY_CLIENT Why does it block some Ajax call but not the others and what causes that? Is there any workaround other than telling user to turn off adblocker? 11 Answers 11

What is the motivation behind the introduction of preflight CORS requests?

Cross-origin resource sharing is a mechanism that allows a web page to make XMLHttpRequests to another domain (from Wikipedia). I’ve been fiddling with CORS for the last couple of days and I think I have a pretty good understanding of how everything works. So my question is not about how CORS / preflight work, it’s … Read more