在函数中访问javascript数据
我有这个功能:在函数中访问javascript数据,javascript,function,variables,Javascript,Function,Variables,我有这个功能: function formSubmitted(json, grandTotal) { $.ajax({ type: "POST", url: "../quotes/create", data: { quote: { name: json.name, json: JSON.stringify(jso
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!");
}
});
}
这一切都很好,但我想做的是重定向窗口。位置在成功:到
http://www.example.com/thanks?id=json.id
json.id与
uid: json.id,
在上面的代码中。我需要做些什么才能让它工作
“…谢谢?id=“+json.id
完美。想让它成为一个答案,我会接受的?最好把你的问题收起来:)这是一个简单的印刷错误,它并不真正属于这样的问题。
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!");
}
});
}