How to show a page where a DIV is with jQuery
Hello I have a DIV in the page index.html:
<div id="form"></div>
Now I need a way with jQuery to show another page inside that DIV. The page I need to call and load there is contact.php It is a simple HTML + PHP contact form. Is there a way to load with jQuery the contents of contact.php inside ind开发者_如何学Pythonex.html page where the DIV is? Thanks for your help!
$("#form").load("contact.php");
The jQuery load function fetches data from the server (in this case from contact.php) and replaces the contents of the selected element (in this case #form) with that data.
If necessary, you can also pass data into the page being loaded, and also supply a callback function that will be executed upon completion.
For more information, see the jQuery API.
You probably want to use an <iframe> element. It would look something like this:
<iframe id="form" src="contact.php"></iframe>
This will load contact.php in a separate frame within your index.html, and you can style iframe#form in the same way that you would style a <div>.
加载中,请稍侯......
精彩评论