我试图通过Javascript使用WolframAlpha的API。我不明白为什么下面的代码会返回一个空警报。我是jQuery的新手,但有人告诉我这是在这里使用的最好方法。
<html>
<head>
<script src="jquery-2.1.1.min.js"></script>
</head>
<body>
<script>
$.get('http://api.wolframalpha.com/v2/query?appid=77P9PL-2QAWEY86WV&input=2x&format=image,plaintext', function(responseText) {
alert(responseText);
});
</script>
</body>
</html>非常感谢你的帮助
发布于 2014-11-28 00:34:25
因此,这是一种名为“跨源脚本”的安全机制。这里的问题是,您正在调用的服务没有允许您在ajax调用中调用该资源。
要阅读更多关于sharing的内容,请看
要证明这种情况正在发生,请看JS:http://jsfiddle.net/dgohczvf/1/
您可以在控制台中看到:
(index):1 XMLHttpRequest cannot load http://api.wolframalpha.com/v2/query?appid=77P9PL-2QAWEY86WV&input=2x&format=image,plaintext.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://fiddle.jshell.net' is therefore not allowed access.这里的另一个答案是,您需要将此服务器调用到服务器:Wolfram API javascript cross origin sharing issue
https://stackoverflow.com/questions/27177898
复制相似问题