Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
jQuery ajaxTransport extension that uses XDomainRequest for IE8 and IE9.
https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
Last synced: 13 days ago
JSON representation
jQuery ajaxTransport extension that uses XDomainRequest for IE8 and IE9.
- Host: GitHub
- URL: https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
- Owner: MoonScript
- License: mit
- Created: 2011-11-18T02:13:40.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2016-04-22T18:15:07.000Z (over 8 years ago)
- Last Synced: 2024-09-30T21:37:11.885Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 396 KB
- Stars: 951
- Watchers: 46
- Forks: 319
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Cross-Domain AJAX for IE8 and IE9
Implements automatic *Cross Origin Resource Sharing* support using the `XDomainRequest` object for IE8 and IE9 when using the [$.ajax](http://api.jquery.com/jQuery.ajax/) function in jQuery 1.5+.
> **CORS** requires the `Access-Control-Allow-Origin` header to be present in the AJAX response from the server.In order to use `XDomainRequest` in Internet Explorer, the request must be:
- Only GET or POST
- When POSTing, the data will always be sent with a `Content-Type` of `text/plain`
- Only HTTP or HTTPS
- Protocol must be the same scheme as the calling page
- Always asynchronousWorking example here:
http://jsfiddle.net/MoonScript/Q7bVG/show/## Instructions
With at least jQuery version 1.5, just include the [jquery.xdomainrequest.min.js](http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js) script into your page, then make your AJAX call like you normally would:
```JavaScript
// GET
$.getJSON('http://jsonmoon.jsapp.us/').done(function(data) {
console.log(data.name.first);
});// POST
$.ajax({
url: 'http://frozen-woodland-5503.herokuapp.com/cors.json',
data: 'this is data being posted to the server',
contentType: 'text/plain',
type: 'POST',
dataType: 'json'
}).done(function(data) {
console.log(data.name.last);
});
```## CDN
This script is hosted by [CDNJS](http://cdnjs.com):
http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js
## Change log
- **1.0.2** - added RequireJS AMD module support
- **1.0.3** - added CommonJS and Bower support
- **1.0.4** - support protocol-relative URLs, use `peerDependencies` in [package.json](package.json)