Jquery load page questions
-
03-07-2019 - |
Question
I am relatively new to using jQuery
and would like to use the load
method to pull in content into my page as the site I am hosting with does not support any server side scripting.
I want to to be able to run more JQuery on the pages that are being pulled in (via the load method) such as the accordian in the UI library. How would I get this to work?
Cheers in advance
Solution
the $.load
method has a callback
.
This will be invoked when the data has been returned so you can instantiate your ui controls in this callback method.
For example
//Load html page with Accordian markup
$('#someDiv').load(urlWithAccordian, function(){
//Create Accordian
$('#someUL').accordian();
});
OTHER TIPS
Change hosts! You should never have to rely on JavaScript for something as rudimentary as content!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow