PDA

View Full Version : Script Not working



BNArun
10-03-2007, 10:29 AM
I'm loading a page dynamically using XMLHttpRequest object. The page that I'm downloading uses an external JavaScript file and after loading content, it calls for a function in that external JavaScript file. When I click on a link, that page will be loaded dynamically using XMLHttpRequest object. But What happening is, that method is not getting called (I placed an alert in that external JavaScript function for debugging purpose). At the same time, if I use that responseText and create a new file with it, then that page is working perfectly and it is calling that JavaScript function and I'm getting alert. What is the problem and what is the solution for it? Help me.

Thanks in Advance.

Mr Moo
10-03-2007, 10:47 AM
I suspect this is because you have an inline script in the page you are loading dynamically. Inline scripts are not evaluated when they are appended to the page. If you have a look at any of the big Ajax frameworks (Prototype (http://www.prototypejs.org/) for example), you'll see that they strip the <script> tags out of the loaded page, append the content, and eval the scripts a millisecond or so later.

BNArun
10-03-2007, 12:18 PM
I suspect this is because you have an inline script in the page you are loading dynamically. Inline scripts are not evaluated when they are appended to the page. If you have a look at any of the big Ajax frameworks (Prototype (http://www.prototypejs.org/) for example), you'll see that they strip the <script> tags out of the loaded page, append the content, and eval the scripts a millisecond or so later.

Then please provide me a solution for it as I have to call those functions and provide me an example if possible that explains the usage of inline script tags.

Thank you very much...