我有这个功能:
function formSubmitted(json, grandTotal) {
$.ajax({
type: "POST",
url: "../quotes/create",
data: {
quote: {
name: json.name,
json: JSON.stringify(json),
email: json.email,
uid: json.id,
grand_total: grandTotal,
postcode: json.postcode,
}
},
dataType:'text',
success: function(data,status,xhr){
console.log(status);
alert("AWESOME!");
window.location.assign("http://www.example.com/thanks?id=json.id")
},
error: function(xhr,status,error){
console.log(status,error);
alert("ERROR!");
}
});
}
一切正常但我想做的是在成功时使用window.location重定向:到
http://www.example.com/thanks?id=json.id
json.id与
相同uid: json.id,
在上面的代码中。我需要做些什么来完成这项工作?
答案 0 :(得分:2)
function formSubmitted(json, grandTotal) {
$.ajax({
type: "POST",
url: "../quotes/create",
data: {
quote: {
name: json.name,
json: JSON.stringify(json),
email: json.email,
uid: json.id,
grand_total: grandTotal,
postcode: json.postcode,
}
},
dataType:'text',
success: function(data,status,xhr){
console.log(status);
alert("AWESOME!");
window.location.assign("http://www.example.com/thanks?id=" + json.id)
},
error: function(xhr,status,error){
console.log(status,error);
alert("ERROR!");
}
});
}