Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Created June 25, 2011 17:46
Show Gist options
  • Save max-mapper/1046704 to your computer and use it in GitHub Desktop.
Save max-mapper/1046704 to your computer and use it in GitHub Desktop.
two ways to do jquery ajax POST requests
// https://github.com/iriscouch/request
var reqOpts = {
uri: "http://awesome.com/upload",
method: "POST",
headers: {"Content-type": "application/json"},
body: '{"awesome":"town"}'
}
$.request(reqOpts, function(err, resp, body) {
var response = JSON.parse(body);
alert(response);
})
// jquery
$.post('http://awesome.com/upload', {"awesome": "town"}, function(response){
alert(response)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment