백그라운드에서 오류를 보고한 json 데이터를 수신할 수 있도록 페이지를 다시 이렇게 쓸 수 있습니다

5741 단어

  
  
  
  
  1. $(function(){ 
  2.         $(inputForm).form({ 
  3.             onSubmit:function(){     
  4.                 var actions = '${ctx}/cthb/cthbapply/applay-input!save.action'
  5.                 var result = validInit(step,actions); 
  6.                 return result; 
  7.             }, 
  8.             success:function(data){ 
  9.                 var result = jQuery.parseJSON(data); 
  10.                 if(result.isok=='T'){ 
  11.                     var cc = result.msg.split(","); 
  12.                     if(cc[1] == 'applay'){ 
  13.                         $("#applayId").val(cc[0]); 
  14.                         stepState = cc[2]; 
  15.                     } 
  16.                     if(cc[1] == 'capital'){ 
  17.                         $("#capitalId").val(cc[0]); 
  18.                         stepState = cc[2]; 
  19.                     } 
  20.                     if(cc[1] == 'applyDoc'){ 
  21.                         $("#docId").val(cc[0]); 
  22.                         stepState = cc[2]; 
  23.                     } 
  24.                      
  25.           $.messager.alert(' '' :  ''info' , function(){ 
  26.                     if(cc[1] == 'applay'){ 
  27.                         jum(0); 
  28.                     } 
  29.                     if(cc[1] == 'knowlageRights'){ 
  30.                         jum(5); 
  31.                     } 
  32.                     }); 
  33.                      
  34.                 }else
  35. $.messager.alert(' '' :'+result.msg, 'error'); 
  36.                 }         
  37.             } 
  38.         }); 
  39.     }) ; 

백스테이지 이렇게 쓰세요.

  
  
  
  
  1. catch (ParseException e) { 
  2.             e.printStackTrace(); 
  3.             JSONObject jobj = new JSONObject(); 
  4.             jobj.put("msg"" !"); 
  5.             Struts2Utils.getResponse().setContentType("text/html;charset=UTF-8"); 
  6.             Struts2Utils.getResponse().getWriter().write(jobj.toString()); 
  7.             return null

좋은 웹페이지 즐겨찾기