我正在通过使用jQuery ajax向PHP控制器发出AJAX请求,但是当试图使用PHP获取发布的数据时,$ _POST为空。以下是实际功能:AJAX post在服务器端为空(PHP)
function GetSeriesForManufacturer(manuf) {
selectedmanufacturer = manuf;
//Make an AJax Call For Getting Series Of Manufacturer
var series = null;
$.ajax({
type: "POST",
url: url,
data: "{manufacturer:'" + selectedmanufacturer + "'}",
contentType: "application/json", //; charset=utf-8",
dataType: "json",
cache: false,
async: false,
success: function (response) {
//remove loading gif
$(".loading").hide();
//Append Data
AppendSeries($.parseJSON(response.text), selectedmanufacturer);
//Custom Scrollbar Call
$('.MatchingSeries ul').mCustomScrollbar();
},
error: function (XMLHttpRequest, textStatus, errorThrown) { }
});
}
在此先感谢!
凡定义'url'? – CD001 2014-12-03 13:18:02
谢谢你的回答,我刚刚用“url”取代了实际的url,帖子正常发生,正如我在firebug控制台中看到的。 – Panos 2014-12-03 13:19:17
问题可能出在这一行上:'data:“{manufacturer:'”+ selectedmanufacturer +“'}”,'。字符串或对象,而不是具有对象的JS表示的字符串。尝试'数据:{制造商:selectedmanufacturer},'而不是。 – 2014-12-03 13:20:17