跨域脚本错误? [英] Cross domain scripting error?
本文介绍了跨域脚本错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码从雅虎财务中提取股票价格
I'm using the following piece of code to pull a stock price from yahoo finance
<script type="text/javascript">
$(function() {
$("#quote").load("http://finance.yahoo.com/q?s=utg #yfs_l10_utg").text();
});
</script>
我收到以下错误:-
Security Error: Content at file:[file url] may not load data from http://finance.yahoo.com/q?s=utg.
和
Error: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "[file url]"]
源文件:[url]
有人对我如何解决这个问题有任何想法吗?
anybody have any thoughts as to how i might get around this?
推荐答案
JavaScript安全模型不允许您加载域外内容.在jQuery .getJSON文档上对此有很好的解释以及一些变通方法: http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback
The JavaScript security model doesn't allow you to load off-domain content. There's a good explanation of this and some work-arounds on the jQuery .getJSON docs: http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback
这篇关于跨域脚本错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文