2

I have requirement in which I need to load application using Ajax, in the application I am loading few javascripts.

  <script type="text/javascript" src="some.js"></script>

Now the problem is that, When I load application directly (without ajax) it works fine, but when I load application using ajax; javascripts are not getting loaded.

3
  • 2
    If I understood the situation correctly, jquery library is being included more than once in a single page? Commented Jan 18, 2013 at 9:32
  • it's just an example, it could be other js also. Commented Jan 18, 2013 at 9:33
  • Do you use live() or on() of jQuery? Commented Jan 18, 2013 at 9:38

2 Answers 2

2

Are you trying to dynamically load JavaScript files?

If so, AJAX is not your friend. You can just add a SCRIPT tag to the DOM.

var jsTag = document.createElement("script");
jsTag.src = "some.js";
document.getElementsByTagName("body")[0].appendChild(jsTag);

Of course, this particular example requires that you have a body element to attach the script tag to...

Sign up to request clarification or add additional context in comments.

Comments

0

use jquery ajax method ajax.getScript ,i guess you are doing dynamic loading,so you need to register scrips after ajax call.

refer http://api.jquery.com/jQuery.getScript/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.