I want to match any raw script in an Ajax downloaded document, so I tried
$.ajax({
url: url,
type: "post",
success: function (data, status, xhr) {
var scr = $(data).find('script[type="text/javascript"]');
The call is returning sucess, but the selector is not returning a match i.e.
'script[type="text/javascript"]'
has a length of 0.
The page being loaded (i.e. data
) definitely contains a test script tag like this:
<script type="text/javascript">
$(function () {
alert("JS running");
});
</script>
What am I missing here? Is it the way JQuery parses raw HTML?
Followup:
this also returns no matches:
var scr = data.find('script');
Note: Looking at the contents of $(data) it appears the JQuery parser strips out any Javascript tags.