1

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?

4
  • 3
    So many duplicates... did you even try searching for a solution first? Commented Sep 9, 2010 at 20:34
  • 2
    That should be enough for this question api.jquery.com/jQuery.get Commented Sep 9, 2010 at 20:36
  • 1
    None suited you? I'm not sure I understand what you mean.. Commented Sep 9, 2010 at 20:41
  • Damn, I was such an idiot back then. Commented Jul 20, 2012 at 16:06

2 Answers 2

10

Pretty basic.

jQuery.ajax() – jQuery API

You'll find lots of examples near the bottom.

Sign up to request clarification or add additional context in comments.

Comments

7

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.