Uncaught TypeError: Cannot set property 'value' of null

前端 未结 8 949
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 07:58

I\'m trying to pass the entered text to the controller using an ajax request. But i\'m getting athe error \"Uncaught TypeError: Cannot set property \'value\' of null \" whe

8条回答
  •  生来不讨喜
    2020-12-05 08:35

    The problem is that you haven't got any element with the id u so that you are calling something that doesn't exist.
    To fix that you have to add an id to the element.

    
    


    And I've seen too you have added a value for the input, so it means the input is not empty and it will contain text. As result placeholder won't be displayed.

    Finally there is a warning that W3Validator will say because of the "/" in the end. :

    For the current document, the validator interprets strings like according to legacy rules that break the expectations of most authors and thus cause confusing warnings and error messages from the validator. This interpretation is triggered by HTML 4 documents or other SGML-based HTML documents. To avoid the messages, simply remove the "/" character in such contexts. NB: If you expect to be interpreted as an XML-compatible "self-closing" tag, then you need to use XHTML or HTML5.

    In conclusion it says you have to remove the slash. Simply write this:

    
    

提交回复
热议问题