AJAX post在服务器端(PHP)是空的
AJAX post is empty on the server side (PHP)
我正在使用jQuery ajax向PHP控制器发出AJAX请求,但是当尝试使用PHP获取发布的数据时,$_POST是空的。下面是实际功能:
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) { }
});
}
提前感谢!
首先,您不需要字符串化数据。只需发送对象文字即可。
data: {manufacturer: selectedmanufacturer},
其次,您不需要此行:
contentType: "application/json",
让 jQuery 为你做编码:
$.ajax({
type: "POST",
url: url,
data: {
manufacturer: selectedmanufacturer
},
contentType: "application/json", //; charset=utf-8",
dataType: "json",
cache: false,
async: false,
success: function (response) {
...
},
error: function (XMLHttpRequest, textStatus, errorThrown) { }});
相关文章:
- 404在Jquery AJAX JSON PHP POST上找不到
- 参数使用AJAX的PHP POST不起作用
- PHP post-id无法使用Javascript变量作为id
- 如何使用AJAX打印PHP POST数据?(没有jQuery)
- 将php post数据传递给javascript的方法
- 如何将PHP Post数据获取到jquery ajax请求中
- jQuery/PHP-POST-Forbidden(403)当试图在我的JSON数据中发送完整的URL时
- 如何使用javascript将所选项目放入php post数组中
- 通过 php post 在 html dom 中发送文本
- PHP POST and Javascript?
- jQuery/PHP Post Failure
- Ajax jquery php post beginner
- JQuery PHP$.post()服务器响应将不起作用
- 从Javascript弹出窗口获取值-用作php post值
- php post显示空消息,没有输出
- 在php-post方法中使用jquery
- 使用Javascript设置隐藏字段值;使用PHP post方法发送数据
- 我将如何得到我在PHP post多个提交按钮点击按钮
- PHP post请求数据检索使用Jquery AJAX
- Ajax PHP post与会话不会给出结果