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?
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);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.