我正在尝试使用带有ajax的jquery加载函数作为使用iFrame的替代方法。
我的代码是:
<asp:UpdatePanel ID="upQnA" runat="server">
<ContentTemplate>
<div id="dQnA" style="position:relative" title="QnA" >
QnA</div>
<script type="text/javascript">
$(function () {
$("#dQnA").load("http://www.google.com", function (responseText, statusText, xhr) {
if (statusText == "success")
alert("Successfully loaded the content!");
if (statusText == "error")
alert("An error occurred: " + xhr.status + " - " + xhr.statusText);
});
});
</script>
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="tmLanding" EventName="Tick"/></Triggers>
</asp:UpdatePanel>
但是当我点击google页面的搜索按钮时,页面会刷新,而不会显示结果QnA
。我想知道如何使用jquery load函数保持代码在div中加载的功能。