如何让回显的结果显示回显的页面索引.php脚本执行操作的地方.php
示例索引.php调用 action.php(AJAX) 一旦所有操作都成功.php将回显一些文本。然后索引.php显示这个
window.alert(data);
$('#data').val('Sent');
A 当我把它放在窗口中的那一刻.alert,但我不希望没有警报,只有文本出现在索引上.php来自回显操作.php
<script>
// initiate the document for data
$(document).ready (
function()
{
// I declare here id of object and action event
$('#msg').on('click', function() {
//to disable button after click
// code here for disable button
var info = $('#name').val();
$.ajax({
method: "POST",
url: "actions/action_comment.php",
//pass my variables to ajax - jq here in data name:
data: {
//id is id of the profile you are viewing eg , who the comment is for
name: info, recptid: '<?php echo $_GET["id"]; ?>' ,
//que is the username of the profile you are viewing (not you) eg name of person comment is for
name: info, q: '<?php echo $userrecivmsg; ?>' ,
// myid is the id OF YOU eg id of person sending the comment
name: info, myid: '<?php echo $myid; ?>' ,
// me is the username of YOU eg name of person sending the comment
name: info, me: '<?php echo $usersendingmsg; ?>'
},
//feed the success my data to return results
success: function(data){
$('#data').append(status);
//ON THIS LINE I WOULD LIKE TO HAVE TEXT DISPLAYED ONLY NOT AS AN ALERT OR DIALOG BOX
window.alert(data);
$('#data').val('Sent');
} // end
}); // end
// STOP DEFAULT BEHAVIOR
return false;
}); // end
}); // end
</script>
谢谢,再次感谢
在索引中添加要显示结果的元素.php
示例<div id="showResult"></div>
然后在你的success function in ajax
$("#showResult").text(data);