0

I am trying to display currency information on my website. I can get currency from a website for free. I would like to display this information by putting the workload on user's browser.

I want to get xml with JSONP, parse it and display the currency with all JQuery. Here is my code below

function GetTodayCurrency() {
    $.get("http://www.tcmb.gov.tr/kurlar/today.xml", function (response) {
        alert(response.html)
    }, "jsonp");
}

But this gives me error. It says "Uncaught SyntaxError: Unexpected token <". I think it gives me this error because there quotation in the xml.

How can I do this proper way? Is it a good practice to put this workload to Javascript? Is it better to do it on server side?

1 Answer 1

1

you can use this plugin to do the Cross origin Request : http://www.ajax-cross-origin.com/

$.ajax({
  url: 'http://www.tcmb.gov.tr/kurlar/today.xml',
  crossOrigin: true,
  type: 'GET',
  success: function(res) {
    $('#container').text(res.responseText);
  }
});
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.