簡體   English   中英

jQuery getJSON無法看到console.log

[英]jQuery getJSON cannot see console.log

我正在使用以下get getJSON

$.getJSON("js/production-data.json").done(function(response) {
    console.log(response);
    console.log('hello');
  });

我可以在Firebug中看到正在檢索數據,但是沒有console.log作為response ,它是整個數據。 我什至都看不到hello

嘗試指定回調內聯,例如:

var jqxhr = $.getJSON( "example.json", function() {
  console.log( "success" );
});

下一步,添加一個always處理程序,而不是僅done

$.getJSON("data.json", function(d) {

  }).done(function(d) {
    console.log("success");
  }).fail(function(d) {
    console.log("error");
  }).always(function(d) {
    console.log("complete");
  });

還可以通過JSONLint驗證JSON

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM