2014-10-30 79 views
2

我有这样的功能:访问的功能的JavaScript数据

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, 

在上面的代码中。我需要做些什么来完成这项工作?

+3

'“...... thanks?id =”+ json.id' – andlrc 2014-10-30 16:51:39

+0

完美。想让它成为答案并接受不适? – MikeHolford 2014-10-30 16:54:26

+0

更好的只是关闭你的问题:)这是一个简单的印刷错误,它不属于SO。 – andlrc 2014-10-30 16:56:44

回答

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!"); 
      } 

     }); 
}