$.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