Skip to content

Instantly share code, notes, and snippets.

@boris317
Created September 12, 2018 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boris317/7f96e08ec2cdf900cb5bb10941cbd003 to your computer and use it in GitHub Desktop.
Save boris317/7f96e08ec2cdf900cb5bb10941cbd003 to your computer and use it in GitHub Desktop.
POST with ajax
$("#newDeviceForm").submit(function(e) {
// Don't let the browser submit automatically
e.preventDefault();
$.ajax({
type: "POST",
url: "http://rad8prod-env.paxsdtgzng.us-east-1.elasticbeanstalk.com/devices",
headers: {
Authorization: "dev_env_pw"
},
data: this.serialize(),
success: function(result) {
console.log(result);
// In here you would inject the response back into the html
// $("#resultDiv").innterHtml = result or something like that.
},
error: function(result) {
console.log(result);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment