1
I have an AJAX Cross-Domain request that receives an XML. After a lot of work, I was able to download the XML but I don’t know if I did it the right way because it never arrives in Success. Follow 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 downloading XML, it is shown in the Google Chrome console the following error message speaking XML: Uncaught Syntaxerror: Unexpected token < in row 1 (header).
View your browser’s Network, and see the status of this request whether it is 200, 304, 403, 404 or 500
– Tafarel Chicotti
@Tafarelchicotti but I don’t want to treat the mistake, I want it not to have to be wrong.
– tiagopotencia
@Tafarelchicotti status 200. I edited the question and put an error message that Google Chrome displays referring to XML.
– tiagopotencia
Tell me which line is going wrong?
– Tafarel Chicotti
@Tafarelchicotti line 1. Logo on the header.
– tiagopotencia
where you put
jsonp
, mute toxml
– Tafarel Chicotti
@Tafarelchicotti there the cross-Omain doesn’t work. Gives permission error: "Xmlhttprequest cannot load http://finansite-a.ae.com.br/localiza/xml/localiza.xml. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost:3064' is therefore not allowed access".
– tiagopotencia
poem as
html
the return and uses thevar $xml = $(data).parseXML();
and try to see if it goes– Tafarel Chicotti