在我的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