JQuery Function import html from external source
I have this JQuery function:
function addSomeHTML()
开发者_如何学C {
$("#mysection").html("<div id='myid'>some content here</div>");
}
I basically need this part: <div id='myid'>some content here</div>
to be read from an external file.
Can anyone help please?
Thanks
Use the AJAX load()
method.
$('#mysection').load('yourfile.html');
Of course the URL can also point to a PHP script etc.
精彩评论