Why would PHP-generated Javascript not work in file loaded via AJAX? -
i loading .php
file via extjs ajax call this:
menuitemapplication.header.on('click', function() { ext.ajax.request({ url: 'content/view_application.php', success: function(objserverresponse) { var responsetext = objserverresponse.responsetext; regioncontent.update(responsetext); var scripts, scriptsfinder=/<script[^>]*>([\s\s]+)<\/script>/gi; while(scripts=scriptsfinder.exec(responsetext)) { eval(scripts[1]); } } }); });
javascript in loaded .php file executes fine:
<script type="text/javascript"> regioncontent.update('changed region content within application view'); </script>
but if javascript being generated via php, not executed:
<?php echo "<script type=\"text/javascript\">\n"; echo "regioncontent.update('changed region content within application view')';\n"; echo "</script>\n"; ?>
yes responses same, seen in firebug net panel, here javascript works:
and here php-generated javascript, does not work:
how can php-generated javascript execute?
those responses aren't same. check '; versus ; @ end there.
<?php echo "<script type=\"text/javascript\">\n"; echo "regioncontent.update('changed region content within application view')';\n"; echo "</script>\n"; ?>
versus
<?php echo "<script type=\"text/javascript\">\n"; echo "regioncontent.update('changed region content within application view');\n"; echo "</script>\n"; ?>
Comments
Post a Comment