使用#.getJSON从另一个域获取json

时间:2015-03-17 20:43:19

标签: jquery json

我正在尝试在我的网页中获取json,但问题是127.0.0.1:8111上的json,我需要使用json回调。但是从localhost接收数据后:8111我收到语法错误意外符号':'。 这是代码

 var wtAPI = 'http://localhost:8111/indicators?callback=?';
$.jsonp({
                    url: wtAPI,
                    type: "GET",
                    callbackParameter: 'callback',
                    dataType: "jsonp",
                     success: function(json){
                    console.log(json)
    },
    error: function(){
        alert('error')
    }

也试过标准

$.getJSON(...)

但这种方式通常不适用于不同的域名

这是我的JSON

 {
    "valid": true,
    "speed": 70.410828,
    "pedals": -0.005646,
    "pedals1": -0.005646,
    "pedals2": -0.005646,
    "pedals3": -0.005646,
    "pedals4": -0.005646,
    "pedals5": -0.005646,
    "pedals6": -0.005646,
    "pedals7": -0.005646,
    "pedals8": -0.005646,
    "stick_elevator": 0.140294,
    "stick_ailerons": 0.000214,
    "vario": 15.953083,
    "altitude_hour": 749.124939,
    "altitude_min": 749.124939,
    "bank": 0.036605,
    "turn": -0.000850,
    "compass": 46.545422,
    "clock_hour": 9.450000,
    "clock_min": 27.000000,
    "clock_sec": 30.000000,
    "manifold_pressure": 1.330175,
    "rpm_min": 674.000000,
    "rpm_hour": 2674.219971,
    "oil_pressure": 88.618057,
    "oil_temperature": 88.618057,
    "water_temperature": 96.471817,
    "mixture": 1.000000,
    "fuel_pressure": 8.834542,
    "gears": 0.500000,
    "gears_lamp": 1.000000,
    "flaps": 0.500000,
    "trimmer": 0.170344,
    "throttle": 0.883454,
    "weapon1": 0.000000,
    "weapon2": 0.000000,
    "prop_pitch": 0.970864,
    "supercharger": 0.000000,
    "radiator": 0.974724
}

0 个答案:

没有答案