The documentation for $.ajax states that script tags are evaluated
when doing an $.ajax call:
http://docs.jquery.com/Ajax/jQuery.ajax#options

dataType:
   "html": Returns HTML as plain text; included script tags are
evaluated.

However, that doesn't seem to be the case.  My test case is below.  If
the scripts were being executed, I would expect two alerts: the first
"ajax" and the second "done".  Instead I just see "done", both in FF2
and IE7.

I've also tried setting variables in the ajax page and reading them in
the main page (in case there was some anomaly with alert()), but that
didn't work either.

Thanks!
Evan


<!-- main page -->
Hello world.

<script src="/js/jquery-1.2.2.min.js"
        type="text/javascript"></script>

<script>
$(document).ready(function () {
    $.ajax({
        url: '/test_ajax.html',
        cache: false,
        dataType: 'html',
        success: function (data) {
            alert('done');
        },
    });
});
</script>


<!-- ajax page -->
<script>
alert('ajax');
</script>


Reply via email to