1
我試圖發送一個ws使用一些參數的發佈請求。AngularJS Http vs Jquery Ajax
在阿賈克斯我做的:
$.post("http://myWS",{name:"xxx",surname:"yyy"},function(response){
console.log(response);
});
這產生有效載荷:
{name:"xx",surname:"yyy"}
在AngularJS我做的:
return $http({
method: 'POST',
async : true,
cache : false,
url: "http://myWS",
data: {name:"xxx",surname:"yyy"},
});
這產生paylaod:
{"name":"xxx","surname":"yyy"}
正如你所看到的,這個有效負載不同於ajax。
我試圖頭添加到$ http請求:
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
,但結果是一樣的。
可能是什麼問題? 謝謝!
的angular.js請求負載似乎是有效的JSON,而相比之下,jQuery的Ajax調用的有效載荷。 – TheHippo
那不是輸出,而是請求有效載荷 – JackTurky
那就是我的意思。抱歉。 – TheHippo