Forum Member - UzuNarU posted this ajax solution to pull content from an outside page and placing it in a <div> tag in this forum (His code post)... and it's working great for us... with one big exception...

We sometimes have javascript code coming back using this ajax process - and it won't display.

Is there a trick do getting javascript ajax to display a javascript content.

e.g. sample code that could be return using this ajax solution. Apparently we are 'nesting' javascript code.

<script type='text/javascript'><!--// <![CDATA[
var ox_swf = new FlashObject('http://xxxxxxxx/haas_tn468x60.swf', 'Advertisement', '468', '60', '10');
    ox_swf.addVariable('clickTARGET', '_blank');
    ox_swf.addVariable('clickTAG', 'http%3A%2F%2Fxxxxxxx%3D60698__zoneid%3D0__cb%3D655fbc6d60');
// ]]> --></script>

Thanks to anyone who would respond!!

Edit: adding ajax code we are using from UzuNarU's post here to simplify quesiton:

For the people who still look at this thread. This is a AJAX JavaScript which allows you to call an external page, query string or whatever you desire and send it to a specified DIV eg:

<a href="javascript:void()" onclick="javascript:sendRequest('sourcepage?id=34', 'targetdiv')">Link Text</a>
<div id="targetdiv">This is the target</div>

This makes it so that users of your site can see the script being passed to get the results that are displayed.

function createRequestObject() 
    var returnObj = false;

    if(window.XMLHttpRequest) {
        returnObj = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        try {
            returnObj = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
            try {
            returnObj = new ActiveXObject("Microsoft.XMLHTTP");
            catch (e) {}

    return returnObj;
var http = createRequestObject();
var target;
// This is the function to call, give it the script file you want to run and
// the div you want it to output to.
function sendRequest(scriptFile, targetElement)
    target = targetElement;
    http.open('get', scriptFile, true);
    catch (e){
    document.getElementById(target).innerHTML = e;
    http.onreadystatechange = handleResponse;
function handleResponse()
    if(http.readyState == 4) {      
        var strResponse = http.responseText;
        document.getElementById(target).innerHTML = strResponse;
        } catch (e){
        document.getElementById(target).innerHTML = e;

Edited by goldentuna

4 Years
Discussion Span
Last Post by Taywin

You may try to replace symbols... Not sure but please try

//After line 41 in handleResponse(), add this...
strResponse = strResponse.replace(/</g, "&lt;").replace(/>/g, "&gt;");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.