0
私は$ http.get関数からフェッチされたデータセットを表示するホームページを持っています。angularjsの不思議な振る舞い
まあ、初めてページが読み込まれる、それが完全に表示されますが、あなたはページをリロードすれば、それは次のようなエラーが発生する:
今angular.js:13550 SyntaxError: Unexpected token < in JSON at position 695 at Object.parse (native)
、私は別のページに移動してホームに戻ってきた場合ページ、それは正常に動作します。私が再びリロードすると、同じエラーが発生します。
私は何が起こっているのか推測しようとしています。
ここで私はinit関数を投稿:
$scope.init = function() {
functions.loading($scope.loading, true);
$scope.$on('loading', function(evt, value) {
$scope.loading.state = value;
});
angular.element(document).ready(function() {
searchService.search_stats().then(function(response) {
FusionCharts.ready(function(){
var last7days = new FusionCharts({
"type": "column2d",
"renderAt": "last7days",
"width": "100%",
"height": "300",
"dataFormat": "json",
"dataSource": {
"chart": {
"caption": "Volume of Searches - Graph",
"subCaption": "Last 7 days",
"xAxisName": "Last 7 days",
"yAxisName": "Volume of searches",
"theme": "fint"
},
"data": response.data.last7days
}
});
last7days.render();
var search_countries = new FusionCharts({
"type": "maps/world",
"renderAt": "search_countries",
"width": "100%",
"height": "400",
"dataFormat": "json",
"dataSource": {
"chart": {
"caption": "Search Volume by Country - Graph",
"subcaption": "Last 7 days ",
"entityFillHoverColor": "#cccccc",
"numberScaleValue": "1,1000,1000",
"numberScaleUnit": "K,M,B",
"numberPrefix": "$",
"showLabels": "1",
"theme": "fint"
},
"colorrange": {
"minvalue": "0",
"startlabel": "Low",
"endlabel": "High",
"code": "#e44a00",
"gradient": "1",
"color": [
{
"maxvalue": response.data.max/2,
"displayvalue": "Average",
"code": "#f8bd19"
},
{
"maxvalue": response.data.max,
"code": "#6baa01"
}
]
},
"data": response.data.countries
}
});
search_countries.render();
functions.loading($scope.loading, false);
});
});
functions.containerResize();
});
search_statsは工場である:
search_stats: function(a) {
return $http.get('/api/myFunctions/search_stats/', {cache:false});
}
任意のアイデア?
ブラウザの開発ツールを開き、ネットワークパネルをクリックして、実際のJSONがダウンロードされているかどうかを調べます。 –
あなたのリクエストはおそらく失敗しており、サーバーはあなたにhtmlのエラーページを送ります。したがって、 '<'で始まります。 –
@JBNizet、はい、[ネットワーク]タブを開いて、応答がないことを確認しました。大きな文字で表示されます。応答データを読み込めませんでした。しかし、それが本当にうまくいくなら、何が起こっていますか? – domoindal