Ajax Post调用不起作用

时间:2015-07-07 07:17:25

标签: jquery ajax

它没有在服务器上返回FirstName。始终返回null。我无法理解它在做什么?

客户端代码

    url = '/Home/RegisterByFacebook';
    user = '{ FirstName: "firstName"}';
    var userJson = $.toJSON(user);
  //  console.log(userJson);
    $.ajax({
        url: url,
        type: 'POST',
        data: userJson,
        async: true,
        dataType: 'Json',
        contentType: 'application/json; charset=utf-8',
        success: function (response) {
            if (response == "true") {
                window.location.href = "/search/index";
            }
        }
    });

服务器端代码:

    [HttpPost]
    [AllowAnonymous]
      public JsonResult RegisterByFacebook(string FirstName)
      {
        return Json("success", JsonRequestBehavior.AllowGet);
      }

Inspecting Element向我展示了这个:

enter image description here

0 个答案:

没有答案