Uncaught SyntaxError: Unexpected token in JSON at position 0

后端 未结 3 1308
名媛妹妹
名媛妹妹 2021-01-27 09:59

With some help, I have managed to make a form that validates and confirms user password before adding the user to the database. I have encountered some problem as the data of th

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-27 10:38

    Use this in my case there was some null bytes so this i figured out and it fixed my issues.

    var data3 = data.substring(data.lastIndexOf("{")+1,data.lastIndexOf("}"));
          count = $.parseJSON("{"+data3+"}");
          alert( count.firstname ); // firstname is the key so you can use anything to test it.
    

提交回复
热议问题