Jump to content

XmlHttpRequest doesn't parse Javascript


ofs

Recommended Posts

My situation is that I have, for example, "page.php", which contains some external javascripts being called with the <script> tag. However, when I use XmlHttpRequest in, for example, "index.php" to get the result of "page.php", these external javascripts don't seem to be parsed at all. Even if I put the <script> tags in "index.php", it doesn't work. Any ideas of how to get around this?

Link to comment
Share on other sites

I may not have been clear enough. The problem seems to be that since XmlHttpRequest just gets the result of a file and posts it, no more parsing can be done. Is there a way to parse the javascript after the result of the file has been retrieved?

Link to comment
Share on other sites

I've done more testing, and found that if a page being called with XmlHttpRequest has any javascript in it at all, the javascript on that page doesn't work. Is there a way to get it to work?

Link to comment
Share on other sites

If I am understanding you correctly you are wanting to make a javascript call to a page which has JavaScript in it. I guess there are two possibilities on how you want that code run.

 

1) Have the code run in the external page to modify the results before being returned to the calling page. This makes little sense to me since you could do everything within the server-side code. Besides it won't work as the page is never actually loaded into the browser - and it is the browser that runs JavaScript.

 

2) You want to return some JavaScript tot he calling page to be used in that page. This is possible, but without more information on how you are implementing it I can't suggest much of a solution. There's alwasy the eval() function, but that's always a poor choice in my opinion.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.