$.post()提交了数据,return不给跳转


本来Controller接到普通请求,return “somePage”,这样就跳转了。
前台用$.post()提交了数据(不需要回调),我了个大草,return那里就不给跳转了
这样怎么解决?

ajax是无法再controller里面return 跳转的,可以返回后再  ajax的success里面进行  window.location.href

Ajax是异步请求 只会接收最后返回的数据,不会执行页面跳转请求改变url地址,要跳转的话,可以使用window.location.href

$.post()是简写的ajax函数
$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType
});
声明是:
jQuery.post( url [, data ] [, success ] [, dataType ] )
可以在回调函数中处理,或者 .done中处理:
var jqxhr = $.post( "example.php", function() {
  alert( "success" );
})
  .done(function() {
    alert( "second success" );
  })
  .fail(function() {
    alert( "error" );
  })
  .always(function() {
    alert( "finished" );
});

  

Null ModelAndView returned to DispatcherServlet with name 'webmvc': assuming HandlerAdapter completed request handling


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM