Search code examples
javascriptprototypejs

Prototype AJAX responsetext missing the javascript


I can find the JS and HTML code in response by alert(). But i cannot append JS from response to body tag however HTML is appending fine.

new Ajax.Request(product_url, {
    method: 'post',
    onSuccess: function(transport) {
         $$('body')[0].insert(transport.responseText);
    }
});

Solution

  •       new Ajax.Request(product_url, {
               method: 'post',
              onSuccess: function(transport) {
    
                   $$('body')[0].insert(new Element("div",{id:"popup"}));
                   $('popup').innerHTML = transport.responseText;
          }
        });
    

    this gives the solution.