Jquery Autocomplete JSON string parsing error

两盒软妹~` 提交于 2019-12-01 13:38:19

I simply suggest you instead of using any other method you can use :

success: function (data, status, xhr) {
    var jsonArray = JSON.parse(data);  // Normal way
}

Other way

success: function (data, status, xhr) {
    var jsonArray = $.parseJSON(data); // using jQuery
}

In this way it will be converted to a simple JavaScript object which you can easily manipulate on your UI/DOM.

You're right -- your JSON is an array which contains a single object. You're expecting just that object.

Try modifying your code like so:

success: function (data) {
  data = data[0]; 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!