I have a Cross-Domain AJAX request that receives an XML. After a lot of work, I was able to download the XML but I do not know if I did it correctly because it never arrives at success . Here is the requisition code:
function refreshPage() {
$.ajax({ url: 'http://finansite-a.ae.com.br/localiza/xml/localiza.xml',
crossDomain: true,
dataType: 'jsonp',
success: function (response) {
$(response).find('li a').each(function () {
listHref.push($(this).attr('href'));
});
var nome_arquivos = new Array();
var DHTML = (document.getElementById || document.all || document.layers);
var xmlDocWin;
var ini_coluna_win;
function pegarDiv(nome) {
if (document.getElementById) {
this.obj = document.getElementById(nome);
}
else if (document.all) {
this.obj = document.all[nome];
}
else if (document.layers) {
this.obj = document.layers[nome];
}
}
function escrever_campo(id, texto) {
if (!DHTML) return;
var x = new pegarDiv(id);
if (x.obj) {
x.obj.innerHTML = texto;
}
return;
}
function pegaCor(valor) {
cor = 'semvar';
temp = valor.replace(",", ".");
if (parseFloat(temp) == 0)
cor = 'semvar';
else if (parseFloat(temp) > 0)
cor = 'varpos';
else if (parseFloat(temp) < 0)
cor = 'varneg';
return cor;
}
}
});}
When you download the XML, the following XML error message is displayed in the Chrome console: Uncaught SyntaxError: Unexpected token on line 1 (header).