• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 734
  • Last Modified:

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() {

Open in new window

Shaye Larsen
Shaye Larsen
  • 3
1 Solution
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);

Open in new window

Shaye LarsenAuthor Commented:
Right on that was enough to do the trick. Thank you very much!
Shaye LarsenAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now