weixin_33743661 2015-10-29 10:46 采纳率: 0%
浏览 39

API中的解析器错误

I've been trying to connect to the buqzilla api to get the data related to my bug id. I'm getting a response code 200 and while debugging it is showing parser error. I've tried to replace the json formatted values but of no use.

There is also another error regarding the CORS.

Can someone please help with this.Thanks in Advance.

<!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@@",
        "Bugzilla_password": "@@pwd@@",
        "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>

</div>
  • 写回答

1条回答 默认 最新

  • weixin_33681778 2015-10-29 11:03
    关注

    As per Bugzilla API, I have done some changes to your urlx variable and make this working.

    Here is the working demo.

    Hope this is what you want!

    评论

报告相同问题?