Created
September 12, 2018 13:48
-
-
Save boris317/7f96e08ec2cdf900cb5bb10941cbd003 to your computer and use it in GitHub Desktop.
POST with ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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