XDomainRequest
Publicado por Álvaro (2 intervenciones) el 21/07/2008 17:40:04
Hola,
estoy intentando acceder a un fichero alojado en un host remoto.
Lo intento con XDomainRequest, pero con fallido resultado.
El codigo es el siguiente:
function Ajax(){
var xmlhttp=false;
try {
xmlhttp = new XDomainRequest();
} catch (e) {
try {
xmlhttp =new XMLHttpRequest();
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function chn(){
document.getElementById('result').innerHTML = 'Loading...';
var uno;
var dos;
var tres;
uno= document.getElementById('uno').value;
dos = document.getElementById('dos').value;
tres = document.getElementById('tres').value;
xdr = Ajax();
xdr.open("POST", "http://aljegares.com/accom/divisas/calculate.php");
xdr.onreadystatechange=function() {
if (xdr.readyState==4) {
document.getElementById('resultado').innerHTML = xdr.responseText;
}
}
xdr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xdr.send("uno="+uno+"&dos="+dos+"&tres="+tres);
}
Si alguien ve algun error en el código o una solución, le agradecería me respondieran.
Muchas gracias.
Un saludo,
Álvaro.
estoy intentando acceder a un fichero alojado en un host remoto.
Lo intento con XDomainRequest, pero con fallido resultado.
El codigo es el siguiente:
function Ajax(){
var xmlhttp=false;
try {
xmlhttp = new XDomainRequest();
} catch (e) {
try {
xmlhttp =new XMLHttpRequest();
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function chn(){
document.getElementById('result').innerHTML = 'Loading...';
var uno;
var dos;
var tres;
uno= document.getElementById('uno').value;
dos = document.getElementById('dos').value;
tres = document.getElementById('tres').value;
xdr = Ajax();
xdr.open("POST", "http://aljegares.com/accom/divisas/calculate.php");
xdr.onreadystatechange=function() {
if (xdr.readyState==4) {
document.getElementById('resultado').innerHTML = xdr.responseText;
}
}
xdr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xdr.send("uno="+uno+"&dos="+dos+"&tres="+tres);
}
Si alguien ve algun error en el código o una solución, le agradecería me respondieran.
Muchas gracias.
Un saludo,
Álvaro.
Valora esta pregunta


0