gpt4 book ai didi

javascript - 服务器端 AJAX post 为空(PHP)

转载 作者:行者123 更新时间:2023-12-03 11:17:29 25 4
gpt4 key购买 nike

我正在使用 jQuery ajax 向 PHP Controller 发出 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",

关于javascript - 服务器端 AJAX post 为空(PHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27272730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com