2015-10-29 21 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 –