Here's the particular situation: I'm using a bookmarklet to call a .js that sends a POST request to a PHP file on my server. Here's the POST request in the .js file:
var snd = ("qu=" + encodeURIComponent(t) + "&dl=" + encodeURIComponent(dl) + "&dt=" + encodeURIComponent(dt));
xr = new XMLHttpRequest();
xr.open("POST", "http://quotebook.us/s/process2.php",true);
xr.onreadystatechange=function() {
if (xr.readyState==4) {
var xmldoc = xr.responseText;
window.alert(xr.responseText);
}
}
xr.send(snd);
And below is what I'm doing in PHP. But try as I might, I can't figure out how to get something BACK to the .js file so it can display it in an alert (and consequently, so I can confirm that it's sending the data in the first place).
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
echo "This page is not for viewing";
exit;
}
$qo = $_POST["qu"];
$dl = $_POST["dl"];
$dt = $_POST["dt"];
echo "First parm: $qo, second param: $dl, third param: $dt";
?>
Ultimately I want to take these variables and write them to a MySQL database, but I'm at least a day away from learning how to do that...
Any help on this process would be very welcome, I've had a heck of a time finding anything about processing POST requests that AREN'T sent by a user form. Apparently writing bookmarklets that send data to MySQL is a black art ;)