0

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>

I get the following errors:-

Security Error: Content at file:[file url] may not load data from http://finance.yahoo.com/q?s=utg.

and

Error: [Exception... "Access to restricted URI denied"  code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"  location: "[file url]"]

Source File: [url]

anybody have any thoughts as to how i might get around this?

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

See this which details how to use YQL to get jsonp results back from yahoo services

Comments

0

I know this does not help your case but putting it here for any future users that stumble upon this.

If you have access to the target URL service your calling, in PHP you can add the below code snippet to avoid this error.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.