Giter VIP home page Giter VIP logo

jquery-ajaxtransport-xdomainrequest's Introduction

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 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 asynchronous

Working example here: http://jsfiddle.net/MoonScript/Q7bVG/show/

Instructions

With at least jQuery version 1.5, just include the jquery.xdomainrequest.min.js script into your page, then make your AJAX call like you normally would:

// 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.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

jquery-ajaxtransport-xdomainrequest's People

Contributors

cbaxter avatar devongovett avatar fidian avatar jcruz2us avatar moonscript avatar riddla avatar tracker1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.