ユーザーが入力するフォームがあります。ユーザーが作業を終えた後、submit をクリックすると、スクリプトが実行され、いくつかの凝った処理が行われ、finished.php に戻ります。このページには、フォームからの $_POST の結果があります....この新しいページの読み込みで、$_POST の結果に基づいてデータを取得するために ajax 呼び出しを起動する必要があります..
素人のコードで:
$_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>
これについてどうすればいいですか
編集された新しいコード:
<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>