问题描述:

i'm trying to use ipinfodb for marking the user position on gmap.

my jquery code is

$.ajax({

type:"GET",

url:"http://api.ipinfodb.com/v3/ip-city/?key=<my api key>&ip=74.125.45.100",

crossDomain: true,

dataType: 'jsonp',

}

);

but i'm getting the following error on chrome

->Resource interpreted as Script but transferred with MIME type text/html: "http://api.ipinfodb.com/v3/ip-city/?key=141cb28778f3fe2d8e55fdd8e4511ad1777…25.45.100&callback=jQuery1820355858133174479_1352640806111&_=1352640806113".

->Uncaught SyntaxError: Unexpected number

what am i missing here?

网友答案:
    var YOUR_KEY = theKey;//"123"
    var theURL = "http://api.ipinfodb.com/v3/ip-city/?key=" + YOUR_KEY + "&format=json&callback=?";

    $.ajax({
        type: "POST",
        url: theURL,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        method: 'GET',

        success: function (data) {
            alert('worked');
        },

        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('failed');
        }
    });//$.ajax({
相关阅读:
Top