我用AJAX调用天气预报接口时报错
XMLHttpRequest cannot load http://op.juhe.cn/onebox/weat... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
调用url是下面这个,返回的时一个JSONurl:http://op.juhe.cn/onebox/weather/query?cityname=%E6%B8%A9%E5%B7%9E&key=KEY
然而我AJAX调用另一个API时返回一个字符串
url`http://api.hitokoto.cn`却能正确回显。这是什么原因造成的?
是不是返回字符串就不存在跨域问题?返回JSON就要使用跨域策略
相关分类