Skip to content

Instantly share code, notes, and snippets.

@pithyless
Created January 1, 2012 14:02
Show Gist options
  • Save pithyless/1547408 to your computer and use it in GitHub Desktop.
Save pithyless/1547408 to your computer and use it in GitHub Desktop.
jQuery set Headers for $.ajax
// jQuery Headers support for $.ajax
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
}
type: "POST",
url: "/article",
processData: false,
data: jsonData,
dataType: "json",
success: function(json){
do something...
}
});
@nakechai
Copy link

nakechai commented Apr 5, 2018

hello i think only the server can set 'Access-Control-Allow-origin' @lazaropj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment