1

我有一个使用 ajax 填充的 iframe。

$.ajax({
        url: "inbox/search",
        data: dataToSend,
        type: 'POST',
        success: function (serverResponse) {
            //server response came write this to iframe

            var ifrm = document.getElementById('contentframe');
            ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
            ifrm.document.open();
            ifrm.document.write(serverResponse);//server response written
            ifrm.document.close();
        },
        error: function (jqXHR, textStatus, errorThrown) {
            removeThrobber();
            alert("Ajax Request Failed!Text Status:" + textStatus + ",errorThrown:" + errorThrown);
        }

    });

这个新填充的 iframe 包含带有操作的表单标记

<form name="inboxSearchForm" id="inboxSearchForm" commandName="userQueueFilter" action="${pageContext.request.contextPath}/inbox/search" method="post">
<a href="#" id="nextPage" onclick="pageJump(document.getElementById('pageNum').value,'up') ">Next ></a>
</form>

iframe 中有一个链接(称为 Next),它使用 javascript 提交表单

document.getElementById('inboxSearchForm').submit();

单击链接请求http://localhost:8080/Proj/inbox/search会自动中止,并且萤火虫显示请求提交到新 URL“ http://localhost:8080/Proj/landing”这是包含整个内容的主页的 URL。此 URL 位于浏览器 URL 栏。对此行为有任何想法吗?

4

0 回答 0