我正在尝试使用其私有应用程序更新Shopify上的客户标记。我用postman试了一下,一切都很好但是通过AJAX,它带我成功回调而不是错误但是成功我得到auth链接而不是客户记录,就像我进入邮递员。
$.ajax({
type: "POST",
url: "https://secret:[email protected]/admin/customers/1569902297146.json",
contentType: 'application/json',
data: JSON.stringify({
customer: {
id: "1569902297146",
email: "[email protected]",
tags: "loyalty-member"
}
}),
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
你做错了。如果您继续在这样的前端公开密码,您很快就会发现有人会用它将您的所有客户变成色情明星名称,导致您失去工作和信誉。相反,您使用内置在私有应用程序中的应用程序代理来执行非CORS,安全,安全的回调,而不涉及密码。
我没有在互联网上找到任何有效的答案/信息。最后,在使用AJAX进行击中和试用后,我能够获得成功的结果。
$.ajax({
type: "POST",
url: "https://secret:[email protected]/admin/customers/1569902297146.json",
contentType: 'application/json',
crossDomain: true,
data: JSON.stringify({
customer: {
id: "1569902297146",
email: "[email protected]",
tags: "loyalty-member"
}
}),
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});
真正的英雄是crossDomain。我不知道为什么Shopify不允许其PUT和POST请求而不进行crossDomain:true,
我想你不需要使用JSON.stringify
像对象一样发送数据
$.ajax({
type: "POST",
url: "https://secret:[email protected]/admin/customers/1569902297146.json",
contentType: 'application/json',
data: {
customer: {
id: "1569902297146",
email: "[email protected]",
tags: "loyalty-member"
}
},
success: function(msg, b ,b) {
console.log(msg);
},
error: function(a, b, c) {
console.log(msg);
}
});