getJSON doesnt works in Wamp Server
-
18-10-2022 - |
Question
I am developing a web site in localhost with wamp.
I am trying to use $.getJSON in a customer register system to visit an api that only do inserts in database. The code is the following:
function user_register(){
var name = $('.name-input').val();
var id = $('.id-input').val();
var phone = $('.phone-input').val();
var email = $('.email-input').val();
var address = $('.address-input').val();
var password = $('.password-input').val();
var repassword = $('.repassword-input').val();
if(!name)
alert('Por favor, ingrese su nombre.');
else if(!id)
alert('Por favor, ingrese su RIF o cédula.');
else if(!phone)
alert('Por favor, ingrese su número telefónico.');
else if(password != repassword || !password || !repassword)
alert('Las contraseñas suministradas no coinciden.');
else{
console.log("Hola");
$.getJSON("http://localhost/clickpc.com.ve/web/api/userRegister.php?name="+name+"&id="+id+"&phone="+phone+"&email="+email+"&address="+address+"&password="+password, function(data){
console.log("Chao");
if(data.error == "false"){
alert('¡Usted ha sido registrado exitosamente!.');
}
});
}
}
I selected all the variable from inputs elements with those selectors, everything is ok at this point. The if/else script Works fine to prevent empty inputs.
The issue is in the last "else". I can print "Hola" with console.log, but not "Chao". It were a test for $.getJSON.
Where is the problema? Its driving me crazy.
Regards.
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow