【问题标题】:JQuery ajax post throws errorJQuery ajax帖子引发错误
【发布时间】:2018-04-10 18:48:59
【问题描述】:

当我尝试使用 Jquery POST 向服务器发送数据时,出现以下错误。

我做错了什么?

  $('.btnEditUser').click(function () {
          console.log('btn edit user clicked')
          var rowUser = $(this).parent()
          var rowUserData = rowUser.find(":input").val()
          var oForm = new FormData()
          oForm.append("rowUserData", rowUserData)
          console.log("oForm", oForm)
          var sUrl = 'edit-user/'
          console.log("sUrl ", sUrl);
          $.post(sUrl, oForm, function (uData) {
            console.log('SUCCESS')
          })
        })

**

未捕获的类型错误:非法调用 在 e (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:7727) 在 Ab (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:7608) 在 Function.r.param (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:7918) 在 Function.ajax (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:12227) 在 Function.r.(匿名函数) [作为帖子] (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:14489) 在 HTMLButtonElement。 (http://localhost:3000/view-users:62:9) 在 HTMLButtonElement.dispatch (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:3:10316) 在 HTMLButtonElement.q.handle (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:3:8343) e@jquery.min.js:4 Ab@jquery.min.js:4 r.param@jquery.min.js:4 ajax@jquery.min.js:4 r.(匿名函数)@jquery.min.js:4 (匿名)@view-users:62 调度@jquery.min.js:3 q.handle@jquery.min.js:3

**

【问题讨论】:

    标签: jquery node.js ajax


    【解决方案1】:

    你检查过rowUserData的值吗

    var rowUserData = rowUser.find(":input").val()
    

    它不应该返回 HTML 元素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-13
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-10
      • 2018-07-27
      相关资源
      最近更新 更多