[英]window.location.assign with AJAX in Firefox not working
我有以下AJAX POST请求,该请求将序列化的表单数据发送到服务器:
// Handle form submission.
$('#evaluationform').on('submit', function(e){
e.preventDefault();
ajaxObject = {
url: $("#evaluationform").attr("action"),
type: 'POST',
dataType: 'json',
xhrFields: {
withCredentials: true
},
crossDomain: true,
data: $("#evaluationform").serialize(),
};
$.ajax(ajaxObject)
.success(function(data,status,xhr) {
window.location.assign("http://example.com/survey/instruction/thankyou.html");
})
.fail(function(data,status,xhr) {
window.location.assign("http://example.com/survey/instruction/fail.html");
})
.always(function(data,status,xhr) {
console.log(status);
});
});
在Chrome和Safari中遵循分配路径,但在Firefox中不遵循。 在Firefox中,该分配将被忽略,而是将我吐出到表单的action属性中定义的API URL。
我一直使用这种语法,并且对我有用: window.location = 'http://www.somesite.com';
: window.location = 'http://www.somesite.com';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.