some ...">

JQuery html import function from external source

I have this jQuery function:

function addSomeHTML() { $("#mysection").html("<div id='myid'>some content here</div>"); } 

I basically need this part: <div id='myid'>some content here</div> to read from an external file.

Can anyone help?

thanks

+4
source share
1 answer

Use the AJAX load() method.

 $('#mysection').load('yourfile.html'); 

Of course, the URL can also point to a PHP script, etc.

+5
source

All Articles