js代码不适用于Web托管,但它适用于localhost
问题描述:
I'm trying to run some AJAX code on my web hosting. The problem is that it works on my localhost but it doesn't work on my web hosting. Do anybody know how to solve this problem?
This is the code:
function validarCorreo(mail){
var bool = false;
var mail = {"mail" : mail};
$.ajax({
data: mail,
url: '/carepets/validaciones/validarCorreo.php',
type: 'post',
async: false,
success: function(response){
if(response == true){
$("#autenticacionCorreo").html("El correo esta disponible.").css("color","green");
bool = true;
}else{
$("#autenticacionCorreo").html("El correo esta ya registrado o es incorrecto.").css("color","red");
}
}
});
return bool;
}
我正在尝试在我的网络托管上运行一些AJAX代码。 问题是它可以在我的localhost上运行,但它不适用于我的虚拟主机。 有人知道如何解决这个问题吗? p>
这是代码: p>
function validarCorreo(mail){
var bool = false;
var mail = {“mail”:mail};
$ .ajax({
data:mail,
url:'/ carepets / invalidaciones / validarCorreo.php',
n type:'post' ,
async:false,
success:function(response){
if(response == true){
$(“#autenticacionCorreo”)。html(“El correo esta disponible。”)。css(“ color“,”green“);
bool = true;
} else {
$(”#autenticacionCorreo“)。html(”El correo esta ya registrado o es incorrecto。“)。css(”color“, “red”);
}
}
});
返回bool;
}
code> pre>
div>
答
Two things you should check: Check if you properly included jQuery in your project. Also check if relative path of validarCorreo.php file is correct on your server and if it is ok then check if there are no errors in that file. It would be good if you could check your Network Activity tab to see and share with us what happens when you invoke validarCorreo function.