我用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就要使用跨域策略
js跨域問題?
白衣染霜花
2018-09-13 13:15:24