开发者

Call PHP page via jQuery/Ajax

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 re开发者_StackOverflow中文版turn it's output (which would be "Hello World!")

How is this done?


Pretty basic.

jQuery.ajax() – jQuery API

You'll find lots of examples near the bottom.


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);
   }
 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜