Skip to content

Implement ajaxSetup for reverse compatibility with $.ajaxSetup

Choose a tag to compare

@bmomberger-bitovi bmomberger-bitovi released this 11 Oct 15:26
· 112 commits to master since this release

Example usage

var ajax = require("can-ajax");
ajax.ajaxSetup({
  lang: "de"
});

Will set the language to German for each request generated by can-ajax.

The xhrFields option is also now available in calls to ajax.ajaxSetup() and ajax():

  ajax({
    type: "GET",
    url: "https://example.com/api/users",
    xhrFields: {
      withCredentials: true
    }
 });

Enables CORS for the cross-domain request.