$ .ajax和JSONP.Uncaught SyntaxError:意外的令牌<

时间:2014-02-16 06:23:30

标签: javascript jquery ajax jsonp

我不断得到一个Uncaught SyntaxError: Unexpected token <,我不能为我的生活找出原因。

    function democracyMap(resp) {
    representative.fullName = resp.jurisdictions[5].elected_office[0].name_full;
    representative.face = resp.jurisdictions[5].elected_office[0].url_photo;
    representative.district = resp.jurisdictions[5].name;

    senator1.fullName = resp.jurisdictions[6].elected_office[0].name_full;
    senator1.face = resp.jurisdictions[6].elected_office[0].url_photo;

    senator2.fullName = resp.jurisdictions[6].elected_office[1].name_full;
    senator2.face = resp.jurisdictions[6].elected_office[1].url_photo;

    representativeInfo();
    senator1Info();
    senator2Info();
    apiSuccess();
}


function ajaxFail(req, status, err) {
    console.log('something went wrong', status, err);
}

function getDemocracyMap(){     

    $.ajax({
        type: "GET",
        url: "http://api.democracymap.org/",
        data:"location=",
        crossDomain: true,
        dataType: "jsonp",          
        success: function(resp) {
            democracyMap(resp);
        },
        error: ajaxFail
    });
}

每个代表,以及发送者1和参议员都被设置为全局变量:

var representative = {
    "fullName": "",
    "firstName": "",
    "lastName": "",
    "district": "",
    "face": "",
    "party": "",
    "termStart": "",
    "termEnd": "",
    "facebookID": "",
    "twitter": "",
    "youTube": ""
}

0 个答案:

没有答案
相关问题