December 2013
Intermediate to advanced
384 pages
9h 54m
English
var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("email").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET","getUserEmail.php?userid=brad",true); xmlhttp.send();
To send a GET request from JavaScript, you first need to implement an onreadystatechange event handler to handle the response or responseText values. Then you need to call open("GET", URL) to open the connection and send() to send the request.
The following code shows an example of a GET request that is sent to the web server via JavaScript. The user value is added to the query string in line 15. Figure ...
Read now
Unlock full access