Skip to content

Instantly share code, notes, and snippets.

@ecarnevale
Created August 26, 2009 08:55
Show Gist options
  • Select an option

  • Save ecarnevale/175405 to your computer and use it in GitHub Desktop.

Select an option

Save ecarnevale/175405 to your computer and use it in GitHub Desktop.
// [jQuery] Headers support for $.ajax
// RPC and REST systems recommend using the HTTP ACCEPT header here is how to use them with jQuery
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
}
type: "POST",
url: "/JSON-RPC",
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