Skip to content

Instantly share code, notes, and snippets.

@eculver
Created November 20, 2009 23:12
Show Gist options
  • Save eculver/239868 to your computer and use it in GitHub Desktop.
Save eculver/239868 to your computer and use it in GitHub Desktop.
set custom headers with jquery $.ajax
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
}
type: "POST",
url: "/someurl",
processData: false,
data: jsonData,
dataType: "json",
success: function(json){
do something...
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment