Holas comunidad, no se si alguien me puede decir si este codigo javascript con metodo ajax es incompatible con Google Chrome, ya el formulario envía en otro navegadores menos en chrome:
Código Javascript
:
Ver originalvar http_request = false;
var clicks = 0;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
document.getElementById('myspan').innerHTML = result;
} else {
alert('Hubo un problema en la Solicitud.');
}
}
}
function get(obj) {
var varSex="";
if(document.getElementsByName("Sexo")[0].checked){
varSex = document.getElementsByName("Sexo")[0].value;
}else if(document.getElementsByName("Sexo")[1].checked){
varSex = document.getElementsByName("Sexo")[1].value;
}else{
varSex = "";
}
var poststr = "Nombre=" + encodeURI( document.getElementById("Nombre").value ) +
"&Pais=" + encodeURI( document.getElementById("Pais").value ) +
"&Telefono=" + encodeURI( document.getElementById("Telefono").value )+
"&Correo=" + encodeURI( document.getElementById("Correo").value )+
"&Sexo=" + encodeURI(varSex) +
"&Edad=" + encodeURI( document.getElementById("Edad").value )+
"&Permanencia=" + encodeURI( document.getElementById("Permanencia").value )+
"&Fecha=" + encodeURI( document.getElementById("Fecha").value )+
"&Encontro=" + encodeURI( document.getElementById("Encontro").value )+
"&Comentarios=" + encodeURI( document.getElementById("Comentarios").value )+
"&url=" + encodeURI( document.getElementById("url").value )+
"&capt=" + encodeURI( document.getElementById("capt").value )+
"&Submit=" + encodeURI( document.getElementById("Submit").value );
makePOSTRequest('http://www.vivatoursperu.com/captcha/c-envio-solicitud.php', poststr);
}
function write_captcha(){
define('Nombre', 'string', 'Nombre');
define('Correo', 'email', 'E-mail');
define('Pais', 'string', 'País');
define('capt', 'string', 'Captcha');
clicks++;
document.getElementById('capt').value = ''
document.getElementById('captcha_id').innerHTML = '<img src="http://www.vivatoursperu.com/captcha/captcha_img.php?clicks=' + clicks + '" border="0" alt="" /><a href="#" onclick="write_captcha();"><img src="http://www.vivatoursperu.com/captcha/png_bank/refresh.gif" border="0" alt="" /></a><br />Escribe los caracteres de la imagen';
return false;
}
Gracias y Saludos!!