0

我有下面這段代碼,我試圖從外部URL檢索數據。當我嘗試執行此操作時,出現401-未經授權的訪問錯誤。請諮詢從外部URL訪問數據問題 - jsonp/json方法不起作用

<script type='text/javascript'> 



    function checkBlueLight() { 

     $('#trBlueLight').hide(); 

     $.getJSON('http://.../Lights/getBlueLight?callback=?', function (data) { 
      if (data.expDate != null) { 
       $('#trBlueLight').show(); 
      } else { 
       $('#trBlueLight').hide(); 
      } 
     }); 
     } 



    </script> 

回答

0

嘗試使用$.ajax代替:

$.ajax({ 
    url: 'http://.../Lights/getBlueLight', 
    dataType: 'json', 
    success: function(data) { 
     if (data.expDate != null) { 
      $('#trBlueLight').show(); 
     } else { 
      $('#trBlueLight').hide(); 
     } 
    } 
}); 
+0

它也不能工作。一樣的問題 – itdeveloper 2013-05-05 02:05:47