Reputation: 193
I have this situation:
I pass a variable via url to an HTML page. The page grabs it via javascript and load via ajax a portion of HTML stored in a file. The first html page (the one who read the variable via url) has some scripts in it.
How can i get them working? I tried with:
$.get('/it_IT/eni_nel_mondo/'+page, function(data){
$('body').prepend(data);
});
It reads the content and it seems also the scripts, but it doesn't execute them.
I pasted the entire code here: http://jsbin.com/uceper (it doesn't display anything, so get the source)
Upvotes: 0
Views: 103
Reputation: 35852
The script existing in your HTML fragment (or HTML portion as you mentioned) won't be executed, maybe because there is no entry point for it. I mean for ajax-loaded scripts, DOMReady won't fire. I suggest using self-invoked functions.
Update: this function won't be executed when loaded via ajax:
function getTime()
{
// Getting the time;
}
but would be executed this way:
(function getTime()
{
// Getting the time;
})();
Upvotes: 1