2015-10-29 60 views
0

我一直在嘗試連接到buqzilla api以獲取與我的錯誤ID相關的數據。我收到響應代碼200,並在調試時顯示解析器錯誤。我試圖替換json格式的值,但沒用。解析器錯誤API

還有一個關於CORS的錯誤。

有人可以幫助這個。感謝提前。

<!DOCTYPE html> 
 
<html> 
 

 
<body> 
 
    <p id="demo"></p> 
 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
 
    <script type="text/javascript" src="http://jquery-json.googlecode.com/files/jquery.json-1.3.min.js"></script> 
 
    <script> 
 
    function Call() { 
 

 
     var requiredParameters = [{ 
 
     "Bugzilla_login": "@@[email protected]@", 
 
     "Bugzilla_password": "@@[email protected]@", 
 
     "include_fields": "id" 
 
     }]; 
 

 
     var connectionObject = { 
 
     params: JSON.stringify(requiredParameters) 
 

 
     }; 
 

 
     var bugId = 19301; 
 
     var urlx = "http://engbugzilla:9898/" + "bug/" + bugId; 
 
     alert("here"); 
 
     debugger; 
 
     $.ajax({ 
 

 
     type: "GET", 
 
     async: true, 
 
     url: urlx, 
 
     contentType: "application/json", 
 
     dataType: "jsonp", 
 
     crossDomain: "true", 
 
     data: connectionObject, 
 
     success: function(data) { 
 
      alert("json"); 
 
     }, 
 
     error: function(xhr, ajaxOptions, thrownError) { 
 
      alert(thrownError); 
 
      console.log(thrownError); 
 
     } 
 

 
     }); 
 

 
    } 
 

 
    Call(); 
 
    </script> 
 

 
</body> 
 

 
</html>

回答

0

Bugzilla API,我已經做了一些更改urlx變量,使這個工作。

這裏是工作demo

希望這是你想要的!

+0

我使用的URL是bugzilla託管的服務器url(本地服務器)。 –

+0

您是否可以從本地'http:// engbugzilla:9898/bug/19301'訪問網址。那是什麼輸出? – deepakb

+0

不支持Content-Type text/html –