使用AJAX传输不了值时

当时候AJAX往后台传递值时  传不到后台  这时我们就要检查程序是否有问题了 

一般AJAX程序

$.ajax(
{
type: "POST",
url: "Login.aspx/Log",
data: JSON.stringify({ "zh": zhanghao, "pwd": mima }),
contentType: "application/json",
dataType: "json",
async: false,
cache: false,
success: function (data)

当使用时往后台传输不了值时  我们就检查一下 是否该换一下传输方式了

以下是该之后的格式

$.ajax(
{
type: "POST",
url: "User.ashx?action=UserEdit",
data: { FId: FId },
contentType: "application/x-www-form-urlencoded",
dataType: "json",
async: false,
cache: false,
success: function (data)

data 换了值的格式

{ FId: FId },

contentType:换了传值的路径

"application/x-www-form-urlencoded"

猜你喜欢

转载自www.cnblogs.com/yutang-wangweisong/p/11530378.html