关于 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 哪里写的不对吗

图片描述

阅读 3.3k
2 个回答
$.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"

就可以了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题