weixin_33711641 2019-04-24 10:24 采纳率: 0%
浏览 66

$ .ajax数据为空

I need to save the record in the database. I have been doing this thing but I don't know for what reason it is giving me this error. Any help will be appreciated. I don't know why the data is null. Please refer to the error show in below screenshot:

data is not defined

data is undefined.

 function submit(amount) {
    var _url = ' /Home/SaveDepositedAmount';
    console.log(_url);
    $.ajax({
        type: "POST",
        async: false,
        cache: false,
        beforeSend: function () { ShowLoading(); },
        url: _url,
        processData: false,
        contentType: false,
        dataType: 'json',
        data: { amount: amount },
    })
    .done(function (data) {

Server side code is:

    [HttpPost]
    public JsonResult SaveDepositedAmount(int amount)
    {
        JsonResult result = new JsonResult();
        int userId = Authentication.Instance.User.UserId;
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
    }
  • 写回答

2条回答 默认 最新

  • weixin_33743248 2019-04-24 10:29
    关注

    You’re passing an object through to the server side but it’s only expecting an int. Create an object with 1 property (int Amount) and use that instead of the int for your server side parameter

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题