Reputation: 857
I've read the many questions and answers on this, but I can't seem to get any of them working. I've reduced this to as small as I can to save brain space.
index.html:
<html>
<head></head>
<body>
<script type="text/javascript">
var ajax = new XMLHttpRequest();
someData = '9876324iuygweighfds';
ajax.open("POST", 'http://www.server.com/ajaxTest.php?a=123', false);
ajax.setRequestHeader("Content-type",'application/upload');
ajax.send(someData);
document.write(ajax.responseText);
</script>
</body>
</html>
ajaxTest.php:
<?php
$a = $_POST['a'];
echo "This is the server. <br>".$a."<br>";
?>
All I get back is:
This is the server.
The actual goal is to send image data gleaned from a canvas and some parameters in one go. Driving me crazy. I'm probably missing something simple, so I thank you and apologise - it's been a very long day :-)
Upvotes: 0
Views: 54
Reputation: 89
You just need to change this part of your own code.
<?php
$a = $_GET['a']; // HEREEEEEE \o
echo "This is the server. <br>".$a."<br>";
?>
Upvotes: 1
Reputation: 1369
You need to set someData = 'a=123';
if you'd like to access it as a POST variable.
Alternatively you could change your PHP to $a = $_GET['a'];
Upvotes: 1