385 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 4-5 years
  • United Kingdom
  • Referred between 100 and 199 users
  • Bought between 10 and 49 items
  • Exclusive Author
EugeneO says

I need help from you Javascript / Ajax gurus.

I have a page with a series of links. When a link is clicked a colorbox window opens and the content from the link is displayed in the window via Ajax. This works fine.

The problem I am having is that when I try to load content that includes a script tag, the script tag is not output at all. My understanding is that when content is loaded via Ajax any script tags should be removed from the content and output after the rest of the HTML . For some reason my script tag is not being readded.

I have tested the code in the script tag to make sure it works and it does so I am confident that is not the problem.

Any ideas?

252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
der says

Well, here’s what you could do: Instead of sending the tags to the client, you could instead send the URLs of such scripts. After you receive the URLs in the AJAX response, you can create an array with those URLs.

You can then pass the array of script urls to head.js. The scripts can be loaded either synchronously or asynchronously (in parallel, but execute in order), your call.

Also, you can run a callback after all the scripts have been loaded, maybe the initialization code that should be run after all the scripts are loaded. If you’re including such initialization code in one of the scripts, there is no need to do so, since the scripts are executed after they are loaded into the DOM .

Hope it helps ;)

by
by
by
by
by
by