最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Call PHP page via jQueryAjax - Stack Overflow

programmeradmin0浏览0评论

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!")

How is this done?

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!")

How is this done?

Share Improve this question asked Sep 9, 2010 at 20:32 testtest 18.2k67 gold badges172 silver badges245 bronze badges 4
  • 3 So many duplicates... did you even try searching for a solution first? – user229044 Commented Sep 9, 2010 at 20:34
  • 2 That should be enough for this question api.jquery.com/jQuery.get – cichy Commented Sep 9, 2010 at 20:36
  • 1 None suited you? I'm not sure I understand what you mean.. – jrharshath Commented Sep 9, 2010 at 20:41
  • Damn, I was such an idiot back then. – test Commented Jul 20, 2012 at 16:06
Add a comment  | 

2 Answers 2

Reset to default 10

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)

  1. 暂无评论