我编写了一个自定义的HTTP处理程序(.ashx),并从.aspx页面调用它。我正在从.ashx发送Javascript代码-- .alert()显示了代码。然而,.eval()似乎什么也不做。会出什么问题呢?
我已经验证了,当我直接在一个普通的旧HTML文件中使用生成的Javascript时,它工作得很好。
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url: "http://localhost/SimpleApp/SimpleHandler.ashx",
context: document.body,
success: function(data) {
alert(data);
eval(data);
}
});
return false;
});
</script>发布于 2011-12-20 09:10:27
不要那样做。试试这个:
<script type="text/javascript">
$(document).ready(function() {
$.getScript({
url: "http://localhost/SimpleApp/SimpleHandler.ashx",
success: function() {
// do something after ashx (js) had been executed.
}
});
return false;
});
</script>https://stackoverflow.com/questions/8569453
复制相似问题