如何使用 ajax 在 showModelDialog 中提交表单后在父窗口中显示结果

How to display results in parent window after form submission in showModelDialog box using ajax

本文关键字:结果 窗口 显示 提交 何使用 ajax showModelDialog 表单      更新时间:2023-09-26

>我面临着父窗口调用showModelDialog提交表单的复杂情况。提交表单后,它将转到 struts2 操作。操作执行一些工作,然后再次重定向到父页面。因此,将再次刷新整个父页面。我希望在用户单击子窗口中提交后。子窗口应关闭,并且仅在父窗口的特定部分需要更新结果。

调用子窗口的函数:

function createRegularFile()
    {
     var userAgent =  navigator.userAgent;
    var appName = navigator.appName;
    window.name="WorklistFiles";
    alert("before="+UserFiles.innerHTML);
    if(appName=="Microsoft Internet Explorer")
    {       window.showModalDialog("createFilePrepareFilesAction.action",window,"help:no;dialogheight:400px;dialogwidth:500px;status:0;");
        }
    else{var abc=window.open("createFilePrepareFilesAction.action","window","HEIGHT=400,WIDTH=500,screenX=80,left=300,screenY=50,top=200,scrollbars=1,resizable=yes");
}

子窗口中的功能:

function create()
{   
    //other code 
    document.createRegularFile.action="createFileFilesAction.action";
    document.createRegularFile.submit();
    window.close();
}

操作代码:

createFile()
{
//some code.
return "parent"
}

支柱.xml:

<result name="parent" type="redirect-action">
                <param name="actionName">worklistWorklistAction</param>
                <param name="error">${error.get(0)}</param>
</result>

父母.jsp

Contains code which displays a table using <s:iterator>

提交成功后,只需更新此表。我知道如何使用AJAX,但在这种情况下找不到实现它的方法。

关闭子项的大纲

<input type="button" onclick="ajax_call();" />
function to_close_child()
{
// code to close child window
}
function ajax_call()
{
//ajaxfunction
  success
   {
     // no need to call on success func
   }

// call the close function here only
to_close_child();
}