406 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $250,000+ on Envato Market
  • Located in United Kingdom
  • Has been part of the Envato Community for over 4 years
+5 more

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?

263 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Won a competition
  • Has been part of the Envato Community for over 5 years
+5 more

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 ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes