Topic: jQuery prepend external javascript.

I have a very wierd problem. I need to prepend external javascripts in to my DOM and i am getting redirected but if i refresh than it works find.

I want to add the game Super Mario ( smile ) into the DOM.

<script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script>
<script type="text/javascript" charset="utf-8">
  if (WIDGETBOX) WIDGETBOX.renderWidget('e1ed0284-eeeb-4b95-905f-2924e23bddbd');
</script>

If i add this to my website without Ajax than it works perfect. But if i try to do WIDGETBOX.renderWidget i get redirected to cdn.widgetserver.com/something.....

this is my jQuery code:

$(selecter).prepend('<script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script><script type="text/javascript" charset="utf-8">if (WIDGETBOX) WIDGETBOX.renderWidget("e1ed0284-eeeb-4b95-905f-2924e23bddbd");</script>')

I am not surprised that it isnt working.... because i call javascript when i think the javascript file isnt loaded. But i am clueless how to solve this problem.

If somebody wants to have a look thanks a lot!

Michael

Re: jQuery prepend external javascript.

If somebody wants to know a solution.

If you want to inject exteded javascript you can do it in the head of an iframe.