es131245 Posted March 21, 2012 Share Posted March 21, 2012 here is the situation Im loading a content of a page using ajax.Content looks like... <script>...</script>Page content... after loading page content js can't find a function that ive loaded by ajax.Ive planed to use body part js on each page. Doing Solutions from google like:1 <script id="traLaLa"></script> document.getElementById('traLaLa').src='/source/EveryPageJsCode.js';2 eval('<script> Every Page JS here... Link to comment Share on other sites More sharing options...
justsomeguy Posted March 21, 2012 Share Posted March 21, 2012 The browser doesn't automatically execute Javascript code that is part of HTML that was later added to the page using something like innerHTML. The best way may be to return a JSON structure which has an HTML section and a Javascript section, and you can add the HTML on the page where it goes and then use eval to execute the Javascript part. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.