Forum Moderators: open
Now this would be fine if I was feeding the script with a POST form or such, but I'm using AJAX to update the tabs.
How do I dynamically update my page with the JS at the url?
I tried:
switch(getCheckedValue(document.forms['myForm'].elements['type']))
{
case 'frame':
//tab = '<iframe src="'+ajaxRequest.responseText+'" width=100% height=7000></iframe>';
tab = '<script src="'+ajaxRequest.responseText+'"></script>';
break; Where tab is the contents of the tab, but the script just ends because I don't know how to escape </script> (I tried '<'+'script/>' and things to no avail.)
Keep in mind the iframe I am including this in doesn't have <script> tags around it.
Thanks a lot guys!
if you load AJAX that contains a <script>, then inject that HTML into your DOM, the script you received will usually execute
does ebay's API URL "contain" JS, or is it actually a script, with mimetype text/javascript and the whole enchalada?
try:
someElementOnYourPage.innerHTML = ajaxRequest.responseText
The way the tabs are created is through a built in function createNewTab() which takes tab as an argument. My declaration of tab behaves correctly if i document.write() it, but then it opens in a new window when I want it to be in a frame. Perhaps the tab scripts I'm using don't allow js inside the tabs.
If I do it through the iframe method (which is commented out on my code posted above), I just see the source code -- it's not being parsed. I think the easiest thing will be for me to throw together a perl script which adds <script> tags to that then I can just put it in an iframe.
Lately I've been using Mootools JS library, which comes with a "Asset.javascript [docs.mootools.net]" class - essentially you can load up an external javascript and execute it with one line of code. Worth a look; might be ideal for what you're doing.