日期:2014-05-17  浏览次数:20675 次

json,action,jsp的问题,困扰好几天了
流程是这样,一个jsp里有左右两个iframe,分别是a.jsp   b.jsp
a.jsp有个文本框,一个按钮,以表单形式提交到action里,再转换成json数据,
传递到b.jsp的js里面进行处理,不知道哪里出了问题(第一次接触这个)
action代码: JSONArray jsonArray = JSONArray.fromObject(listt); //list转换为json数组 
PrintWriter out=null;
out = resp.getWriter();
out.print(jsonArray.toString());
out.flush();
out.close();
return null;
xml配置文件:<action name="target" class="com.action.TargetAction">
<result name="histo">/history/zuoce.jsp</result>
<result name="histmap">/history/ditu.jsp</result>
<result type="jsom"></result>
</action>
现在凌乱了,不知道怎么做...
jsp json js

------解决方案--------------------
$(document).ready(function(){
        $("#Button1").click(function(){
                $.ajax({
                    type: "post",
                    url: "<%=basePath%>/log/query.action?method=query",
                    data: "name=" + $("#Text1").val(),
                    dataType:"json/xml/html",   
                    success: function (result){
                        try{
                    var obj = eval('('+result+')');  
            alert(obj.name);
                 }catch(e){
                   window.location="../index.jsp"
                 }
                  }
                }); 
                });   
            }); 
------解决方案--------------------
引用:
Quote: 引用: