Loading content into a div via jQuery doesn't include external files?

I am loading content from an external file into a div via jQuery.

For some reason, like the other ajax content loading scripts, it does not pull in the javascripts, css files, etc.  which are referenced in my external file, making the page, once loaded, in look like junk. My external file relies completely on the css file it references and also needs a js file too.

I know this can be done because I have used a jQuery lightbox popup that can load its contents via ajax from an external file and it loads including the necessary css and js files.

Does anyone know how to get this to work or knows of a good plugin that will do this?

The below javascript is what I am currently using:
<script type="text/javascript">
$(document).ready(function() {
$("#loadAjaxSite").load("/sitecreator/site_templates/test-green/index.jsp");
});
</script>

Open in new window

LVL 1
Shaye LarsenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaye LarsenAuthor Commented:
Thank you.

I tried it but I can't view it on the page... I only get the alert from the callback.

This is what I did with the script at the link you showed me:
<%
String siteTemplate = "test-blue";//or test-green
%>
<!-- dynamic ajax content to load in template -->
<script type="text/javascript" src="../js/sitecreator_load_ext_files.js"></script>
<script type="text/javascript">
var globalCallback= function(){
alert('all files are loaded!!!');
}
$.include( ['/sitecreator/site_templates/<%=siteTemplate%>/main.css',
'/sitecreator/site_templates/<%=siteTemplate%>/index.jsp'] ,globalCallback);
</script>

Open in new window

0
Shaye LarsenAuthor Commented:
Right on that was enough to do the trick. Thank you very much!
0
Shaye LarsenAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.