$.ajax({
type: 'POST',
data: 'search_condition=' + this.search_condition,
url: _this.url_.BASE_URL + '/Select/ConditionSelectInOrOutList.php',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (data) {},
error: function (data) {}
})
如果ajax请求代码是如上所示,这里会得不到数据,会出现error的情况。
原因就是如果请求方式为POST,且请求接口时携带参数data,那么contentType要改成
contentType: 'application/x-www-form-urlencoded; charset=utf-8'
这样 就不会报错了。