Created
January 12, 2018 08:43
-
-
Save wiyoe/2a7aeacde3d104ea9c1f6247da21d391 to your computer and use it in GitHub Desktop.
Sending and Receiving JSON- Native
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
| var xhr = new XMLHttpRequest(); | |
| xhr.open('PUT', 'myservice/user/1234'); | |
| xhr.setRequestHeader('Content-Type', 'application/json'); | |
| xhr.onload = function() { | |
| if (xhr.status === 200) { | |
| var userInfo = JSON.parse(xhr.responseText); | |
| } | |
| }; | |
| xhr.send(JSON.stringify({ | |
| name: 'John Smith', | |
| age: 34 | |
| })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment