<script type="text/javascript">
function a(){
var type=$("#type").val();
var title=$("#title").val();
var content=$("#content").val();
$.post("saveArtiles.action",{"articles.type":type,
                                "articles.title":title,
                                "articles.content":content},function(data){
                   location.href="findAllArt.action";
                    })
}
</script>
  </head>
  
  <body>
    <table>
     <tr>
     <td>标题:</td>
     <td><input id="title"/></td>
     </tr>
     <tr>
     <td>内容:</td>
     <td><input id="content"/></td>
     </tr>
     <tr>
     <td>类型:</td>
     <td><input id="type"/></td>
     </tr>
     <tr>
     <td><input type="button" onclick="a()"/></td>
     </tr>
    </table>
  </body>上面是我的页面代码   只要文本框里面没有值它就能成功得跳action 但是一有值就不行了  求解是为什么啊

解决方案 »

  1.   

    这里面js出错了,你打下alert看看哪个行出问题了。
    function a(){
    var type=$("#type").val();
    var title=$("#title").val();
    var content=$("#content").val();
      

  2.   

    关键是报什么错呢?
    js代码没看到什么问题
    加上type="text"试下。
    <script type="text/javascript">
    function a(){
    var type=$("#type").val();
    var title=$("#title").val();
    var content=$("#content").val();
    $.post("saveArtiles.action",{"articles.type":type,
                                    "articles.title":title,
                                    "articles.content":content},function(data){
                       location.href="findAllArt.action";
                        })
    }
    </script>
      </head>
      
      <body>
        <table>
         <tr>
         <td>标题:</td>
         <td><input type="text" id="title"/></td>
         </tr>
         <tr>
         <td>内容:</td>
         <td><input type="text" id="content"/></td>
         </tr>
         <tr>
         <td>类型:</td>
         <td><input type="text" id="type"/></td>
         </tr>
         <tr>
         <td><input type="button" onclick="a()"/></td>
         </tr>
        </table>
      </body>
      

  3.   

    话题补充 刚才经过测试 发现三个文本框里 只要第二个里面有值就提交不了  只要第二个里面没值 就可以加载action 
      

  4.   

    findAllArt里面execute进去的地方大断点,并且观察下后台是否有报错。
      

  5.   

    第一步:提交前alert(title),看能不能拿到正确的值
    第二步:在提交的action中也就是findAllArt这个action所对应的方法里把这三个文本框的值打印出来。
    如果第一步测试没问题但第二步没有打印,说明你action的名字、路径或者配置有问题
    如果第一第二步都的值都正常出来了,就是你action方法里写的代码报错了,没有正确返回
      

  6.   

    action 方法写错,关注articles.content