$.ajax(
{
 type: "POST",
url: "sturts2/example/Hello.action",
data:dt,
dataType:"html",
success: 
function(msg)
{
alert(msg);
$("#div2").append(msg);//这里是把得过来msg(jsp页面的内容)加到 div2下面
}
}
)
我想把整个表单提交  $("input[type='text']").each(function(){s += $(this).attr("id")+":"+$(this).val()+",";})
    if(s!='') s = s.substr(0,s.length-1);
    s = "{" + s + "}";
    var dt;
    eval("dt ="+s); 我用这种方式取的可是这种方式只能跑通一次  第2次开始就不行啦   那位兄弟帮忙解决一下?  

解决方案 »

  1.   

    url: "sturts2/example/Hello.action?rnd=" + (new Date()).getTime(),
    防止浏览器缓存
      

  2.   

    $(this).val()两边加单引号
    整个客户端代码贴一下看看,顺序是不是有问题?
      

  3.   

    jq的ajax自带缓存设置了的.
    cache:false,
      

  4.   

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script language="javascript" src="../jquery-1.3.2.js"></script>
    <script type="text/javascript" language="javascript">
    function ajax()
    {
            var s = "";
        $("input[type='text']").each(function(){s += $(this).attr("id")+":"+$(this).val()+",";})
        if(s!='') s = s.substr(0,s.length-1);
        s = "{" + s + "}";
        var dt;
        eval("dt ="+s);
     //   var data1 = $("#form").formSerialize(); 
    // var param = {name:$('#name').val(),pwd:$('#pwd').val()};
    $.ajax(
    {
       type: "POST",
       url: "sturts2/example/Hello.action",
       data:dt,
       dataType:"html",
       success: 
       function(msg)
       {
       alert(msg);
        $("#div2").append(msg);
        }
    }
    )
    }
    </script>
    </head>
    <body>
    <div>
    <input type="text" id="name" />
    <input type="text" id="pwd" />
    <input type="submit" value="submit" onclick="ajax()"/>
    </div>
    <div id="div2"></div>
    </table>
    </body>
    </html>