JQuery unrecognized expression on Ajax response

前端 未结 2 800
时光说笑
时光说笑 2020-12-18 14:12

I have this JQuery Ajax Form.

$(\'#modal-body-sign-in\').on(\'submit\', \'#sign-in\', function(e) {
        e.preventDefault();
        var data = $(this).se         


        
2条回答
  •  萌比男神i
    2020-12-18 15:12

    If you are using jQuery1.9, the problem may lie in the content being loaded. There is a new update which requires that the first character in the response be a < [AKA the less than symbol]. Even whitespace will cause this to break and throw the dreaded "Uncaught Error: Syntax error, unrecognized expression:" error.

    I'd recommend checking this before using the suggested workaround above. Its not a bug its a security effort.

    http://jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring

提交回复
热议问题