0

I'm trying to use javascript to get a csv from a web service hosted by yahoo. I'm pretty new to javascript and webservices so I really don't know whats wrong.

symbol = CSCO

$.ajax({
url: "http://finance.yahoo.com/d/quotes.csv?s=" + symbol+ "&f=price",
type: "GET",
beforeSend: function (xhr) {
    xhr.setRequestHeader("Accept", "text/csv");
},
success:OnSuccessCall,
error: OnErrorCall()
});



function OnSuccessCall(response) {
    alert('woo');
}
function OnErrorCall(response) {
    alert('boo');
} 
3
  • You have an extra closing brace before OnSuccessCall(response) Commented Jun 25, 2013 at 0:22
  • And it should be error: OnErrorCall - without the () Commented Jun 25, 2013 at 0:41
  • We don't know what's wrong too... you need to tell us what kind of error message you're getting. However, I'm pretty sure you're dealing with a cross domain issue. stackoverflow.com/questions/1201429/… Commented Jun 25, 2013 at 1:19

1 Answer 1

1

JavaScript cannot be used for this purpose because of same origin policy.

Your own server needs to retrieve the data from finance.yahoo.com which then can be accessed by JavaScript.

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

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.