问题描述
- EXTjs页面submit后 action.result接收不到参数?? 10C
- 我的目的是 extjs提交form到 process.jsp
process.jsp 处理数据后进行两个操作:
1: 通过out.println() 返回操作结果 true或false 给extjs页面的 action.result
extjs页面根据操作结果关闭窗口
2. process.jsp 通过window.open 弹出新窗口,进行下一个页面的操作 (那一堆js就是弹新窗口的)现在遇到的情况是process.jsp处理数据后,虽然有out.println()返回,但EXTJS页面action.result 接收不到结果
新窗口倒是可以正常弹出
如果去掉弹新窗口的js代码,EXTJS页面action.result 就可以接收到结果了,奇怪啊
1、EXTjs A页面,将信息submit到process.jsp,然后等待操作结果fm.getForm().submit({ url : 'process.jsp' waitMsg : 'Uploading your file...' success : function(fm action) { if (action.result == true) { Ext.MessageBox.alert('OK' 'success.'); window.close(); } } failure : function(fm action) { if (action.result == false) { alert('File upload false.'); } }
2、process.jsp 页面根据obj返回类型,分别返回A页面
out.println(""false""); 和 out.println(""true""); 但A页面action.result 始终接收不到参数
若去掉process.jsp 页面out.println代码下面的js语句则正常,什么原因<% String errorStr = """"; Object obj = Getdata.doprocess(request); if (obj instanceof String && obj.toString().length() > 0) { errorStr = (String) obj; out.println(""false""); %> <script type=""text/javascript""> window.onload=function(){ var newWim=open(""Error.jsp""); newWim.document.write(""<%=errorStr%>""); }; </script> <% }else if (obj instanceof JSONArray){ out.println(""true""); %> <script type=""text/javascript""> window.onload=function(){ var newWim=open('VariantSelection.jsp'); }; </script> <% } %>
解决方案
ExtJS 3.2版本
解决方案二:
jsp要返回json格式字符,你返回的那一堆script代码是要干嘛
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.form.BasicForm-method-submit
submit( options ) : BasicFormShortcut to do a submit action.Available since: 1.1.0Parametersoptions : ObjectThe options to pass to the action (see doAction for details).Note: this is ignored when using the standardSubmit option.The following code:myFormPanel.getForm().submit({ clientValidation: true url: 'updateConsignment.php' params: { newStatus: 'delivered' } success: function(form action) { Ext.Msg.alert('Success' action.result.msg); } failure: function(form action) { switch (action.failureType) { case Ext.form.Action.CLIENT_INVALID: Ext.Msg.alert('Failure' 'Form fields may not be submitted with invalid values'); break; case Ext.form.Action.CONNECT_FAILURE: Ext.Msg.alert('Failure' 'Ajax communication failed'); break; case Ext.form.Action.SERVER_INVALID: Ext.Msg.alert('Failure' action.result.msg); } }});would process the following server response for a successful submission:{success"":true // note this is Boolean not stringmsg"":""Consignment updated""}and the following server response for a failed submission:{success"":false // note this is Boolean not stringmsg"":""You do not have permission to perform this operation""}
解决方案三:
谢谢码农回复
我的目的是 extjs提交form到 process.jsp
process.jsp 处理数据后进行两个操作:
1: 通过out.println() 返回操作结果 true或false 给extjs页面的 action.result
extjs页面根据操作结果关闭窗口
2. process.jsp 通过window.open 弹出新窗口,进行下一个页面的操作 (那一堆js就是弹新窗口的)
现在遇到的情况是process.jsp处理数据后,虽然有out.println()返回,但EXTJS页面action.result 接收不到结果
新窗口倒是可以正常弹出
如果去掉弹新窗口的js代码,EXTJS页面action.result 就可以接收到结果了,奇怪啊