-1

I have a js file and execute with :

<div id="result">
    <script type="text/javascript" src="js/tracking.js"></script>
</div>

My main page has 2 divs (2 colums in page) and there are buttons on the left div. When i click to the first button, i would like to execute js file and display on the right. I can easily handle html files by :

$("#result").load( "test.html" );

But for js files i think i need to use getscript. I gave a shot with :

$("#result").load("#result",function(){$.getScript("js/tracking.js"); });

Ok, it executes the script but not loading into "result" div. It opens a new page and displays the result.

How should i modify?

1

1 Answer 1

-1

As far as I can understand, you want to load, execute & display js file.

check this [demo][1]

  [1]: http://codepen.io/anon/pen/WrYQLX
Sign up to request clarification or add additional context in comments.

8 Comments

Correct! I have a js file and a button. When i click to button, i would like to execute another js file in my div. That js file executes some codes and display some results. Your code is ok but works in html section. Could you please divide the page %30-%70 vertically and put a button in the first div. When clicking the button, please execute another js which displays hello world in the second div. Please do them only in js window.
Please check the updated demo @ codepen.io/anon/pen/WrYQLX and replace "urlforyourscript" in js window with your script url
Ok, Thanks Arun but it displays in another page. $("#trackinginfo").html( '<script type="text/javascript" src="js/tracking.js">' + '</script>' ); or $.getScript("js/tracking.js"); I could not make it display in trackinginfo div dynamically!
Can you create a fiddle for this and let me inspect?
lets continue on your pen. I created a js file very simple : document.write("Hello World!");alert('aaaaaa'); Here : 1fichier.com/?m01luth44c I put this link to $.getScript("1fichier.com/?m01luth44c"); alert function works but i can not see document.write in result div.
|

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.