通过jQuery/Ajax调用PHP页面 [英] Call PHP page via jQuery/Ajax
本文介绍了通过jQuery/Ajax调用PHP页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个PHP页面,在该PHP页面中,我只有<?php echo"Hello World!";?>
,我想使用JavaScript(最好是jQuery)和AJAX来调用该php页面并返回其输出(将是"Hello World!")
Let's say I have a PHP page and inside that PHP page I just have <?php echo "Hello World!"; ?>
and I want to use JavaScript (preferabbly jQuery) and AJAX to CALL that php page and return it's output (which would be "Hello World!")
这是怎么做的?
推荐答案
数据
将包含页面中的文本,并对其进行处理.在这种情况下,请设置 #responseArea
文本以包含该文本.
The data
will contain the text from the page, do what you want with it. In this case, set the #responseArea
text to contain it.
$.ajax({
url: "yourPage.php",
success: function(data){
$("#responseArea").text(data);
}
});
这篇关于通过jQuery/Ajax调用PHP页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文