I have a form that a user completes. after the user is done he clicks submit, the script runs and does some fancy things and returns to finished.php. on this page I have the results of his $_POST from the form....on this new page load, I need to fire an ajax call to get the data based on his $_POST result..
in layman's code:
$_POST['someValue'] = "12345";
$(document).on("pageinit","users/userInfo.php",function(){
$.ajax({
type: "POST",
data:"someValue="+$_POST['someValue'],
success: function(msg){
$('#mainBody').html(msg);
}
});
});
<div id='mainBody'> --Print results of ajax call---</div>
how would i go about this
edited new code:
<script>
$(document).on("pageinit",function(){
$.ajax({
type: "POST",
url: "users/userInfo.php",
dataType: "html",
data:"someValue=+<?php echo $_POST['someValue'];?>",
success: function(msg){
alert('hi');
$('#mainBody').html(msg);
},
error: function(){
alert('failure');
}
});
});
</script>
Your
data:"someValue="+$_POST['someValue'],
Should be
data:"someValue="+<?php echo $_POST['someValue'];?>,
,
or
data:"someValue=<?php echo $_POST['someValue'];?>",
if the $_POST['someValue']
is a string as it will make the javscript error out if you dont put it in quotes.
$(document).on("pageinit",function(){
did not work.
$(document).ready(function(){
did.