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
2 Answers
Reset to default 10Pretty 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);
}
});