I am trying to use the following function to post a single select option value to a pChart
page. When I try to check the form data in developer tools it suggests the name:datastring
pair is being posted to the PHP file. The Javascript file is as follows:
$(document).ready(function() {
$('#players').on('change', function() {
var dataString = $('#players option:selected').val();
$.post("../pChart2.1.3/AllPillarsCoach.php",
{name:dataString},
"
Status: " + status);
});
});
But it shows an empty array:
<?php
echo "<pre>";
var_dump($_POST)."br /";
echo "</pre><br>";
...
?>
I have checked with GET
as well with no success. I don't want a return to the browser as the PHP page renders an image and it doesn't appear too happy about being applied to a div
.
Thanks for the replies so far my original, function was as follows which I truncated to try and make sure that the pChart was going to be parsed.
$(document).ready(function() {
$('#players').on('change', function() {
var dataString = $('#players option:selected').val();
$.post("../pChart2.1.3/All.php",{name:dataString},"
Status: " + status,
function(status){
alert("Data: " + dataString + "\Status: " + status);
});
});
});
The developer tools with both versions suggests that the form data is being posted name= thw17po14 and parsed name: thw17po14. The alert shows both the dataString and the success message. I just want to take the post data as criteria for a query and the resulting chart will be accessed separately so no need for a return to the browser. Alert as it stands now shows the following after changing the "select option", again thanks for any help in advance.
Data: thw17po14Status: <pre>array(1){
["name"]=>
string(9)"thw17po14"
}
</pre><br>