返回JSON对象但无法通过$ .ajax()访问

det*_*llt 1 javascript ajax jquery json

我有一个ASP.NET MVC Web API,我从$ .ajax()方法调用.从我的API返回正确的JSON,但无法访问该对象.尝试记录"名称"的值时,我的控制台收到的错误是:

未捕获的TypeError:无法读取未定义的属性"名称"

JSON:

[{"id":2,"Name":"thom","Picture":"thom.jpg","About":"I'm a guy. This is my profile. Now quit staring and get out of here.","Location":"London"}]
Run Code Online (Sandbox Code Playgroud)

jQuery的:

$.ajax({
            cache:false,
            type: 'GET',
            dataType: 'json',
            url: 'http://localhost:3235/Users/searchUsers?callback=?&searchString=' + searchString,
            complete: function (data) {
                console.log(data[0].Name);
            }
        });
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.谢谢!

Jim*_*ote 9

我想你的意思是使用这个success功能.该complete功能不data作为参数.

  • 我不敢相信我也没注意到:P (2认同)