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

急求:关于jsp页面javascript调用action
页面中有个按钮,点击按钮调用javascript方法,
方法中:function add(){
var url = "record.do?method=recordAdd";
window.location.href=url;
}

action中:return null;

action中方法是一个插入方法,不多说。

我现在想点击这个按钮后页面无改动,但是后台走了action中这个方法。可我现在的程序是点击按钮后,页面跳成空页面了。求教啊。。。
------解决方案--------------------
你return null当然是跳空页面了,你这个需求,点击这个按钮后页面无改动,直接用异步请求就OK了啊,这样写:

function add(){
   $.ajax({
       url:'record.do',
       data:{"method":"recordAdd"},
       dataType:'POST',
       success:function(data){
          ....
       }
   });
}


这样你在Action中return null就没问题。还是在当前的页面。
------解决方案--------------------
楼主去看看AJAX技术
------解决方案--------------------
他写错了。。 dataType:'POST',
------解决方案--------------------
解决了吗。楼主。恭喜