Im using jquery to call a page via ajax. I have some jquery functions that load inside the returned html from the page being called from ajax. The problem is Im trying to include the js file inside the returned data, it gives back the html but seems to strip the script tag:
function buildDisplayResults()
{
$.ajax({
method: 'get',
cache: false,
url : '/display_results.php',
dataType : 'text',
success: function (text) { $('#showresults').html(text); }
});
}
The returned data I have <script src="/js/display.js"></script>
That script code above always gets stripped out, but I need it in the returned data so the functions work inside the data the ajax call sends back. Any ideas?
As far as I can tell, it should work; it must be something else in your environment or in the markup you’re fetching. I’ve tested it and have it working on IE6, IE7, IE8, Chrome 9 on Linux and Windows, Firefox 3.6 on Linux and Windows, and Opera 11 on Linux and Windows; all using jQuery 1.5:
Ajax call on main example page:
…where the
/okuli4/3resource looks like this:…where the
/etobe4/2resource looks like this:Live example