AngularJS $ http意外的令牌冒号 [英] AngularJS $http Unexpected token colon

查看:67
本文介绍了AngularJS $ http意外的令牌冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向远程网站发出获取请求,但得到: 未捕获的SyntaxError:意外的令牌:" 有谁知道我做错了什么吗? 这是我的代码

I'm trying to do a get request to a remote website but I get: "Uncaught SyntaxError: Unexpected token :" Does any one have a idea what im doing wrong? This is the code I have

var url = "http://www.colorfyit.com/api/swatches/list.json?url=facebook.com&callback=json_callback";

    $http.jsonp(url)
        .then(function successCallback(response) { 
            console.log(response); 
        }, function errorCallback(response) { 
            console.log(response); 
        });

推荐答案

它似乎不像colorfyit api支持jsonp.来自 http://www.colorfyit的响应.com/api/swatches/list.json?url = facebook.com& callback = json_callback 为JSON格式,没有像在JSONP响应中那样包装在函数调用中.

It doesn't look like the colorfyit api supports jsonp. The response from http://www.colorfyit.com/api/swatches/list.json?url=facebook.com&callback=json_callback is in JSON format, it's not wrapped in a function call as it would be if it was a JSONP response.

更多信息: JSON和JSONP有什么区别?

这篇关于AngularJS $ http意外的令牌冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆