npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery-transport-xdr

v1.0.11

Published

A jQuery plugin that enables cross-domain AJAX requests for IE8 and IE9 with XDomainRequest.

Downloads

39

Readme

jQuery plugin for cross-domain CORS ajax-requests in Internet Explorer 8 and 9

Internet Explorer 8 and 9 versions doesn't support cross-domain CORS ajax-requests with XMLHttpRequest, for these purposes IE 8/9 using XDomainRequest. jquery-transport-xdr makes transparent replasement jQuery transport, that's allow cross-domain ajax-requests in IE8 and IE9 without changing source code.

Limitations

XDomainRequest have some limitations:

  • server must return Access-Control-Allow-Origin header as for usual CORS request
  • HTTP and HTTPS only allowed
  • GET and POST only allowed
  • custom headers can't be added to request
  • there is no Content-Type header in request
  • Cookie can't be sended
  • source scheme of URI (https://source) must be the same as destination URI scheme (https://destination)
  • there is no ability to get success response code
  • there is no ability to get failure response code

Installation

  1. Add jquery-transport-xdr to HTML body after jQuery:
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<!--[if (IE 8)|(IE 9)]><script src="//cdn.rawgit.com/gfdev/javascript-jquery-transport-xdr/master/dist/jquery.transport.xdr.min.js"></script><![endif]-->

or Bower:

$ bower install jquery-transport-xdr
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<!--[if (IE 8)|(IE 9)]><script src="//host/path/bower_modules/dist/jquery.transport.xdr.min.js"></script><![endif]-->

or NPM:

$ npm install jquery-transport-xdr
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<!--[if (IE 8)|(IE 9)]><script src="//host/path/node_modules/dist/jquery.transport.xdr.min.js"></script><![endif]-->

Usage examples

After adding jquery-transport-xdr you can make ajax-requests as usual, without changing code:

POST:

var xhr = $.ajax({
    type: 'POST',
    url: 'https://baconipsum.com/api/?type=meat-and-filler&format=json',
    dataType: 'json'
});

GET:

var xhr = $.ajax({
    type: 'GET',
    url: 'https://baconipsum.com/api/?type=meat-and-filler&format=json',
    dataType: 'json'
});

Option forceMethod

XDomainRequest have limitations, it doesn't allow PUT, DELETE, PATCH and HEAD requests, you will receive error XXX Method Not Allowed if try to use some of them, but jquery-transport-xdr can make replacement:

  • HEAD => GET
  • PUT|DELETE|PATCH => POST

You should use option forceMethod:

HEAD:

var xhr = $.ajax({
    type: 'HEAD',
    url: 'https://baconipsum.com/api/?type=meat-and-filler&format=json',
    dataType: 'json',
    forceMethod: true
});

HEAD will be replaced with GET in this case and __method=HEAD will be added to request params in URI:

https://baconipsum.com/api/?type=meat-and-filler&format=json => https://baconipsum.com/api/?type=meat-and-filler&format=json&__method=HEAD

Param __method you can get on server and deretmine original method.

The same way for methods PUT, DELETE and PATCH except for param __method will be added to request body and original method will be replaced with POST:

PUT:

var xhr = $.ajax({
    type: 'PUT',
    url: 'https://baconipsum.com/api/?type=meat-and-filler&format=json',
    data: { test: 'test' },
    dataType: 'json',
    forceMethod: true
});

PUT => POST

POST /api/?type=meat-and-filler&format=json HTTP/1.1
Host: baconipsum.com
Connection: keep-alive
Content-Length: 0
Pragma: no-cache
Cache-Control: no-cache

test=test&__method=PUT

Option forceContentType

XDomainRequest limitations doesn't allow to send Content-Type header, but you can send it if will add forceContentType option:

var xhr = $.ajax({
    type: 'POST',
    url: 'https://baconipsum.com/api/?type=meat-and-filler&format=json',
    data: { test: 'test' },
    dataType: 'json',
    forceContentType: true
});

Content-Type value will be sended in __contentType param.

forceContentType and forceMethod options can be used together:

var xhr = $.ajax({
    type: 'PATCH',
    url: 'https://baconipsum.com/api/?type=meat-and-filler&format=json',
    contentType: 'multipart/form-data; charset=UTF-8',
    data: { test: 'test' },
    dataType: 'json',
    forceMethod: true,
    forceContentType: true
});

License

MIT license.