Last active
December 25, 2020 11:59
-
-
Save Shakil-Shahadat/1f45458cca6953f67ebf to your computer and use it in GitHub Desktop.
Ajax POST request with data [ Obsolete, use fetch instead ]
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
let data1 = 'Hello World!'; | |
let data2 = 'Hello Universe!'; | |
let http = new XMLHttpRequest(); | |
http.open( 'POST', 'post.php' ); | |
http.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); | |
http.send( 'data1=' + data1 + '&data2=' + data2 ); | |
http.onreadystatechange = function() | |
{ | |
if ( http.readyState == 4 && http.status == 200 ) | |
{ | |
console.log( http.responseText ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment