How To Load A Php Script Using Ajax?
I would like to know the best technique for loading a PHP page and insert into a section of a page using AJAX? For example, consider the following HTML code:
Solution 1:
$('#web_Content').load('myFile.php');
Solution 2:
I assume you want the page to load in the web_Content
div when a link is clicked, If so, you can do something like this:
$(function(){
$('#web_Menu a').click(function(e){
e.preventDefault();
$('#web_Content').load($(this).attr('href'), function(){
alert('File loaded');
});
});
});
Solution 3:
<scriptsrc="jquery.js"></script>
// dont forget to include jquery script
<scripttype="text/javascript">functiona()
{
var file="otherfilename"; //Enter the name of file, which is to be loaded
$("#load_file").load(file+".php").fadeIn("slow");
}
</script><buttononClick="a();">Read File</button><divid="load_file"> The division where file will be loaded </div>
Easy loading of other .php
file using Jquery, simple and easy.
Post a Comment for "How To Load A Php Script Using Ajax?"