I am doing an jquery ajax call in my rails application and in the controller I am rendering it to a view page(where javascripts codes are written). Then I need to insert the response returned from the server to a DOM element. When I try to alert the server response (alert (data))I am getting it completely. But when I insert it into the dom element($(‘#someid’).html(data)) it is not inserting it completely as it contains lot of javascript codes. So can anyone please tell me how to insert the javascript codes of another view returned from ajax to a view page??
Share
Seems like you have got some issues with escaping characters.
This is a working DEMO
I’m using below code which works fine:
However, it’ll alert even without escaping script tag but will not render and execute it in DOM which I guess highlights your problem.