我可以让Ajax成功发送请求,但我希望它也可以重定向到新页面,而不是重定向。任何人都可以建议一种替代方法或正确的重定向方式吗?
submitHandler: function(form) {
$("div.error").hide();
$.ajax({
type: "POST",
url: '<?php echo base_url().'subscribe/process_payment/'?>',
data: $(form).serialize(),
success: function(msg){
console.log( "Data Saved: " + msg );
},
error: function(msg){
console.log( "Error: " + msg);
}
});
return true;
},
答案 0 :(得分:1)
通常您只需在成功功能
中进行重定向即可success: function(msg){
console.log( "Data Saved: " + msg );
window.location = "mysite.com/newURL";
},
或返回网址
success: function(url){
window.location = url;
},