简体   繁体   English

我有错误未捕获的TypeError:无法读取未定义的属性'toLowerCase'

[英]I have the error Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

error 错误

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined (jquery.min.js:2)
at w.fn.init.val (jquery.min.js:2)
at Object.error (Default.aspx:380)
at u (jquery.min.js:2)
at Object.fireWith [as rejectWith] (jquery.min.js:2)
at k (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)

Hello, that's my error. 您好,这是我的错误。 I search on the web but other solved questions doesn't have the same code as me. 我在网上搜索,但其他已解决的问题与我的代码不同。

My code : 我的代码:

$(".selectProjectElement").change(function () {
            $.ajax({
                method: "POST",
                url: "Default.aspx/affectProject",
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                data: "{ id:" + $(this).parent().parent().attr("data-id") + ", elementCode:'" + $(this).val() + "', userID:'" + $("#hidden_userID").val() + "' }",
                success: function () {
                    alert("reussi");
                },
                error: function (xhr) {
                    alert("F" + $(this).val() + "F");
                    //alert("Une erreur est survenue.");
                    window.location.pathname = window.location.pathname;
                }
            });
        });

I don't know why I have this error and don't find a solution. 我不知道为什么会有这个错误,也找不到解决方法。 Have you an idea ? 你有主意吗? Thank's in advance. 提前致谢。

Sorry for my english. 对不起我的英语不好。

You data line is wrong. 您的数据线是错误的。

It either needs to be: 它要么需要是:

data: '{ "id": "' + $(this).parent().parent().attr("data-id") + '", "elementCode":"' + $(this).val() + '", "userID": "' + $("#hidden_userID").val() + '"}',

or: 要么:

data: { "id": $(this).parent().parent().attr("data-id"), "elementCode": $(this).val(), "userID": $("#hidden_userID").val()},

Personally I would do it with a variable outside 我个人会用一个外部变量来做

$(".selectProjectElement").change(function () {
  var data = { 
    id: $(this).parent().parent().attr("data-id"),
    elementCode: $(this).val(),
    userID: $("#hidden_userID").val()
  }
  $.ajax({
    ...
    data: JSON.stringify(data),
    ...
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的TypeError:无法读取属性toLowerCase的未定义 - Uncaught TypeError: Cannot read property toLowerCase of undefined 未捕获的TypeError:无法在文本字段上读取未定义错误的属性“ toLowerCase” - Uncaught TypeError: Cannot read property 'toLowerCase' of undefined Error on text field 未捕获的TypeError:无法读取未定义的属性“ toLowerCase” - Uncaught TypeError: Cannot read property 'toLowerCase' of undefined 未捕获的TypeError无法读取未定义的属性“ toLowerCase” - Uncaught TypeError Cannot read property 'toLowerCase' of undefined 未捕获的TypeError:无法读取未定义的属性'toLowerCase' - Uncaught TypeError: Cannot read property 'toLowerCase' of undefined 获取错误未捕获的TypeError:无法读取未定义的属性“ toLowerCase” - Getting error Uncaught TypeError: Cannot read property 'toLowerCase' of undefined 未捕获的类型错误:无法读取未定义的属性“toLowerCase”(待办事项列表应用程序) - Uncaught TypeError: Cannot read property 'toLowerCase' of undefined (Todo list application ) Elastic_Grid | “未捕获的TypeError:无法读取未定义的属性&#39;toLowerCase&#39;” - Elastic_Grid | “Uncaught TypeError: Cannot read property 'toLowerCase' of undefined” jsonp请求上的“ Uncaught TypeError:无法读取未定义的属性&#39;toLowerCase&#39;” - “Uncaught TypeError: Cannot read property 'toLowerCase' of undefined” on jsonp request TokenInput +未捕获的TypeError:无法读取未定义的属性“ toLowerCase” - TokenInput + Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM