跨域脚本错误?

我正在使用以下代码来从雅虎财务中提取股票价格

 $(function() { $("#quote").load("http://finance.yahoo.com/q?s=utg #yfs_l10_utg").text(); });  

我收到以下错误: –

 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]

谁有任何想法我怎么可能绕过这个?

JavaScript安全模型不允许您加载域外内容。 对jQuery .getJSON文档有一个很好的解释和一些解决方法: http ://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback

请参阅此内容 ,详细介绍如何使用YQL从yahoo服务中获取jsonp结果

我知道这不会对你的情况有所帮助,而是将它放在任何未来的用户身上。

如果您有权访问目标URL服务,则可以在PHP中添加以下代码段以避免此错误。

 header('Access-Control-Allow-Origin: *');