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);
}
});
精彩评论