Not sure if this should work but from a jquery ajax request with the response I want to evaluate the script being passed back. Here goes for an example.
$.ajax({
url: some/path,
dataType: 'script'
});
Then with my response I'm using php to spit out the javascript.
<?php
header("content-type: application/javascript");
$str = <<<EOF
alert('help');
EOF;
echo $str;
If I'm correct I should get a alert pop-up after performing the request.
I can see from the response headers it correct:
Accept:application/json, text/javascript, */*; q=0.01
And response is:
alert('help');
But no alert box is being triggered. Am I missing something or can this not be done this way?
Hope you can advise.
TY