note 117051 deleted from function.http-request by tularis
| From: | tularis@php.net | Date: | Wed, 08 Apr 2015 14:48:16 +0000 |
| Subject: | note 117051 deleted from function.http-request by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202212@lists.php.net to get a copy of this message | ||
Note Submitter: nikkoz789 at gmail dot com
----
<script type="text/javascript" >
function showPREV(){
var hr; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
hr = new XMLHttpRequest();
}catch (e){
// Internet Explorer Browsers
try{
hr = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try{
hr = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create some variables we need to send to our PHP file
var url = "phpRequest/showPREV.php";
var vars = "accountID="+<?php echo $userID; ?>;
hr.open("POST", url, true);
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("result").innerHTML = return_data;
}
}
// Send the data to PHP now... and wait for response to update the status div
hr.send(vars); // Actually execute the request
document.getElementById("result").innerHTML = "";
}
</script>