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');
} 
  • You have an extra closing brace before `OnSuccessCall(response)` – vee Jun 25 '13 at 00:22
  • And it should be `error: OnErrorCall` - without the `()` – Ian Jun 25 '13 at 00: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. http://stackoverflow.com/questions/1201429/jquery-ajax-fails-when-url-is-from-different-server – The_Black_Smurf Jun 25 '13 at 01:19

1 Answers1

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.

user1255321
  • 41
  • 1
  • 1
  • 5