curl命令与ajax,如何从curl命令转换成Ajax请求

curl -v -H "Content-Type:application/json" -H "X-KGP-AUTH-TOKEN: a5a95c30274611e2ae10000c29bb7331" -H "X-KGP-APPID:id.kenhgiaiphap.kcloud" -H "X-KGP-APPVER:0.0.1" -H "X-KGP-DEVID:xxx" -H "X-KGP-DEVTYPE:xxx" http://test.kenhgiaiphap.vn/kprice/account/profile/get/token

我写AJAX来处理这个

$.ajax({

url: "http://test.kenhgiaiphap.vn/kprice/account/profile/get/token",

type: "POST",

cache: false,

dataType: 'json',

success: function() { alert('hello!'); },

error: function(html) { alert(html); },

beforeSend: setHeader

});

function setHeader(xhr) {

xhr.setRequestHeader('X-KGP-AUTH-TOKEN','a5a95c30274611e2ae10000c29bb7331');

xhr.setRequestHeader('X-KGP-APPVER', '0.0.1');

xhr.setRequestHeader('X-KGP-DEVID', 'xxx');

xhr.setRequestHeader('X-KGP-APPID','id.kenhgiaiphap.kcloud');

xhr.setRequestHeader('X-KGP-DEVTYPE', 'xxx');

}

但我的问题是

2XMLHttpRequest cannot load http://test.kenhgiaiphap.vn/kprice/account/profile/get/token. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

和在请求是

token

test.kenhgiaiphap.vn/kprice/account/profile/get OPTIONS (取消) 负载取消 文本/无格式 jquery的-1.7.2.min.js:2320 脚本 156B 0B 1.15 s 39ms 39ms1.11s

感谢支持!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值