【发布时间】:2013-09-09 11:18:02
【问题描述】:
我已按照this 链接中所述的教程进行操作。在下面的代码中,由于某种原因,数据没有作为参数附加到 url,但是如果我使用 /?field1="hello" 将它们直接设置到 url,它就可以工作。
$.ajax({
url: 'superman',
type: 'POST',
data: { field1: "hello", field2 : "hello2"} ,
contentType: 'application/json; charset=utf-8',
success: function (response) {
alert(response.status);
},
error: function () {
alert("error");
}
});
【问题讨论】:
-
如果您正在寻找要附加到 URL 的参数,您需要将类型更改为“GET”。 'POST' 将改为在 HTTP 标头中传递参数。