语法错误:意外的令牌Ø在Object.parse(本机)AngularJS [英] SyntaxError: Unexpected token o at Object.parse (native) AngularJS

查看:396
本文介绍了语法错误:意外的令牌Ø在Object.parse(本机)AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从AngularJS noob问题。

Question from AngularJS noob.

我试图使用ASMX Web服务显示网格。我测试的Web服务,它正确输出JSON数据。
这里是我的控制器

I am trying to use an asmx web service to display grid. I tested the web service and it correctly outputs the JSON data. Here is my controller

app.controller('SetupController', ['$scope', '$http', function ($scope, $http) {

    var url = 'app/pricefilessetup/grid.asmx/getGridJson';

    $http.get(url).success(function (data) {
        var myjson = JSON.parse(data);
        $scope.products= JSON.parse(myjson);
    });
}]);

由于某些原因,所以没有让我粘贴HTML,但它基本上已经通过JSON数据的NG-控制器指令和NG-重复循环。

For some reason, SO is not allowing me to paste the html but it basically has a ng-controller directive and ng-repeat to loop through the JSON data.

当我运行这个web应用程序,我得到的错误

When I run this web app, I get the error

语法错误:意外的令牌Ø
    在Object.parse(原生)
它指向下面的行

SyntaxError: Unexpected token o at Object.parse (native) and it points to following line

  $scope.questions = JSON.parse(myjson);

我试着用警报检查myjson的值,并将其显示[对象的对象],[对象的对象] ...

I tried checking the value of myjson using alert and it displays [object Object], [object Object], ...

这有什么,我在这里失踪

Is there anything I am missing here

推荐答案

我想返回的数据已经是JSON,无需的JSON.parse()来,除非它字符串格式。

I think data returned is already in JSON, no need of JSON.parse(), unless it in string format.

$scope.products= data;

这篇关于语法错误:意外的令牌Ø在Object.parse(本机)AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆