我想测试一个需要在ajax调用上设置标头的Restful API。这是我要测试的api link。
我已编写此代码以在ajax调用上设置标头。jsfiddle
$(document).ready(function(){
var card = '{ "card_name" : "Alfred Robert Rowe", "card_number" : "4242424242424242", "card_cvc" : "123", "exp_month" : "06", "exp_year" : "2010", "amount" : "300" }';
$.ajax({
url: 'https://app.mpowerpayments.com/sandbox-api/v1/direct-card/processcard',
type: 'POST',
headers: {
"Content-Type":"application/json",
"MP-Master-Key":"dd6f2c90-f075-012f-5b69-00155d866600",
"MP-Private-Key":"test_private_amOI11Gb0SIo6NSLZr1xkfOYSuE",
"MP-Token":"d25e1f4ddc053779d526"
},
data: {data: card},
success: function (e) {
alert(e);
},
error: function (e) { alert(JSON.stringify(e));}
});
});
而不是获得成功代码我甚至没有得到任何东西甚至错误功能警告任何东西
这有可能在php中做一些curl。请帮助我如何执行此测试