0

In jQuery I wrote this simple ajax call to convert from one currency to another using Yahoo's YQL service.

function changeCurrency(amount, currency_from, currency_to) {
    var query = "select%20*%20from%20yahoo.finance.xchange%20where%20pair='" + currency_from + currency_to + "'";
    var urlservice = "http://query.yahooapis.com/v1/public/yql?q=" + query + "&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
    $.ajax({
        type: "GET",
        url: urlservice,
        dataType: "xml",
        success: function(xml) {

            $(xml).find('rate').each(function() {
                var rate = $(this).find('Rate').text();
                var result = Math.round(amount * rate * 100) / 100 ;
                $("#result").html(result + currency_to);
            });
        },
        error: function(xhr, status, error) {
            $.jGrowl(xhr + ' ' + status + " " + error);

        }
    });
}

Heres a live version at jsfiddle.

Its working fine in Chrome, FF and Safari but fails in IE (9) with error message "Access denied". I guess it has to do with security but don't know how to solve it, any suggestions?

Muleskinner
  • 14,150
  • 19
  • 58
  • 79

2 Answers2

0

Try to set IE with low security settings

Michele
  • 681
  • 3
  • 16
  • 27
  • thanks, im using the default security settings when getting the error. It is not an option to go lower on security as it is for a worldwide webapp. – Muleskinner Jan 19 '12 at 14:24
0

Have you seen this question on Stack Overflow? Its quite similar problem and I think you might find the solution for your problem there :)

Community
  • 1
  • 1
mike
  • 550
  • 2
  • 9
  • 24
  • Thanks that's probably it - in the end however, I solved it by moving the yql call to a local web file handler (.ashx file) which then returned the conversion to the browser. This allowed me to solve the problem without having to write browser specific js code. – Muleskinner Jan 19 '12 at 16:25