ajax 响应未按预期进行预处理

ajax response isn't pre-processing as expected

我正在尝试从查询 google 的安全浏览 api 中解析响应数据,响应似乎是一个 javascript 原型对象,我在其中尝试转换或解析为 JSON 时运气不佳。我的 ajax 调用如下:

$( document ).ready(function() {
console.log( "ready!" );

//first fake links and event listeners
AddFakeLinks(faulty_links, curr_list);

//url checker action
$("#my_form").submit(function(event){
    event.preventDefault(); //prevent default action 

    var api_url = "https://safebrowsing.googleapis.com/v4/threatMatches:find?"
    var key = 'AIz________________________ns'
    api_url += "key="
    api_url += key

    var payload = 
    {
        "client":{
            "clientId": "_________________.googleusercontent.com",
            "clientVersion": "1.0.0",
        },
        "threatInfo": {
            "threatTypes":      ["MALWARE", "SOCIAL_ENGINEERING"],
            "platformTypes":    ["WINDOWS"],
            "threatEntryTypes": ["URL"],
            "threatEntries": [
              {"url": "http://www.pitt.edu/"},
              {"url": "http://www.exchange.pitt.edu/"}
            ]
          }
    };

    $.ajax({
        type: "POST",
        url: api_url,
        contentType: "application/json",
        dataType: "json",
        data: JSON.stringify(payload),
        xhr: function(){
            //upload Progress
            var xhr = $.ajaxSettings.xhr();
            if (xhr.upload) {
                xhr.upload.addEventListener('progress', function(event) {
                    var percent = 0;
                    var position = event.loaded || event.position;
                    var total = event.total;
                    if (event.lengthComputable) {
                        percent = Math.ceil(position / total * 100);
                    }
                    //update progressbar
                    $("#upload-progress .progress-bar").css("width", + percent +"%");
                }, true);
            }
            return xhr;
        },
        success:function (data) {
            console.log(data);
        },
        error:function(jqXhr, textStatus, errorThrown) {
             console.error(textStatus, errorThrown) 
        }
    }).done(function(response){
        $("#server-results").html(response);
        console.log(response);
    });

控制台有如下输出:

网络控制台显示响应 200 ok:

这个API我一点都不熟悉。但是在查看文档后,问题似乎是没有匹配您的请求。

https://developers.google.com/safe-browsing/v4/lookup-api

Response body

The response body includes the match information (the list names and the URLs found on those lists, the metadata, if available, and the cache durations). For more details, see the threatMatches.find response body and the explanations that follow the code example.

Note: If there are no matches (that is, if none of the URLs specified in the request are found on any of the lists specified in a request), the HTTP POST response simply returns an empty object in the response body.