I tried to answer all the questions related to this tag but I was not successful where is my mistake?
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://www.tcmb.gov.tr/kurlar/today.xml",
dataType: "xml",
headers: {
'Access-Control-Allow-Origin ': '*'
},
success: function (xml) {
alert("Success");
}
});
});
My error;
Access to XMLHttpRequest at 'http://www.tcmb.gov.tr/kurlar/today.xml' from origin 'http://localhost:44318' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I'm using jquery ajax in asp.net framework.please I tried the answers to all questions please do not throw the question title.
Try this:
$(document).ready(function() { $.ajax({ type: "GET", url: "https://cors-anywhere.herokuapp.com/http://www.tcmb.gov.tr/kurlar/today.xml", dataType: "xml", success: function(xml) { console.log('success') var xmlText = new XMLSerializer().serializeToString(xml); var xmlTextNode = document.createTextNode(xmlText); var parentDiv = document.getElementById('xml'); parentDiv.appendChild(xmlTextNode); } }); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="xml"></div>
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.