Created
May 31, 2017 18:12
-
-
Save seanhess/876b6b0d39dd3241eddd805aa182be18 to your computer and use it in GitHub Desktop.
Cors example
This file contains 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
<html> | |
<script> | |
var xhr = new XMLHttpRequest(); | |
xhr.open("POST", 'http://localhost:8080/applications', true); | |
//Send the proper header information along with the request | |
xhr.setRequestHeader("Content-type", "application/json"); | |
xhr.onreadystatechange = function() {//Call a function when the state changes. | |
console.log("RESPONSE", xhr.status, xhr.readyState) | |
console.log("RESPONSE", xhr.response) | |
} | |
var request = { | |
application: { | |
firstName: "bob", | |
lastName: "wilson", | |
dateOfBirth: "1982-08-11", | |
ssn: "111223333", | |
monthlyIncome: 1234, | |
email: "[email protected]", | |
phoneCell: "8013332222", | |
phoneAlt: "8013332222", | |
address: { street1: "1234 W Street", street2: "", city: "SLC", state: "UT", zipCode: "84601" }, | |
bank: { routingNumber: "123456789", accountNumber: "123456789" }, | |
paymentSchedule: [] | |
} | |
} | |
console.log("SENDING", request) | |
xhr.send(JSON.stringify(request)); | |
</script> | |
<body> | |
Cors test | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment