首页 > 关于 ajax 获取 cnodejs api 数据

关于 ajax 获取 cnodejs api 数据

$.ajax({

            type: "GET",
            
            url: "https://cnodejs.org/api/v1/topic/5433d5e4e737cbe96dcef312",
            
            dataType: "jsonp",
            
            jsonp: "jsoncallback",
            
            success: function (result) {
            
                alert(result);
            
            },
            
            error: function (result, status) {
            
            //处理错误
            
                console.log(result);
            }

    });

返回的结果总是 error 哪里写的不对吗


$.ajax({
        type:"GET",    
        url: "https://cnodejs.org/api/v1/topic/5433d5e4e737cbe96dcef312",
        dataType:"json",
        success:function (result) {
            console.log(JSON.stringify(result));
        },
        error:function (result, status) {
        //处理错误
            console.log(result);
        }
});

这个不用跨域貌似。

同上 不需要跨域。。。

dataType:"json"

就可以了

【热门文章】
【热门文章】