在我的jQuery POST請求的URL被定向到本地主機總是(有消息http://127.0.0.1:8080/MyApp/[object Object])jQuery的POST重定向到http://127.0.0.1:8080/MyApp/[object對象]
有了一個jQuery GET工作正常(連接到外部URL)。
如何更改POST行爲以訪問指定的URL?
var tmpurl='https://myhost.com/message';
$.post({
data: {
'v': value,
'key' : 'MyKey'
},
dataType: 'jsonp',
url: tmpurl,
success: function(response) {
console.log("success!", response);
}
});
你是什麼意思重定向?並嘗試使用json作爲dataType而不是jsonp –
我的意思是它不使用目標url(https://myhost.com/message)作爲目標,但嘗試連接到本地主機。 jsonp用於跨域請求。用json dataType嘗試,但不起作用。 – RajCherla