This is the html div:
<div class="alert alert-success alert-dismissable feedstatus hidden">
<button type="button" class="close" data-dismiss="alert">×</button>
<span class="glyphicon glyphicon-ok-sign" style="color:#0c0; font-size:40px;"> </span></a><br/>Message recieved.<br/>Thanks <strong class="feedbacker"></strong>
</div>
<form role="form" onsubmit="regFeedback()">
<div class="form-group">
<input class="form-control bordering" id="feedbacker" type="text" name="name" placeholder="Name" style="border:none; border:0px solid #fff;" required/><br>
<input class="form-control bordering" id="feedbackemail" type="email" name="email" placeholder="tu@email.com" style="border:none; border:0px solid #fff;" required/><br>
<textarea class="form-control bordering" id="feedback" name="feedback" placeholder="Write me something before go" style="border:none; border:0px solid #fff;" required/></textarea><br>
<button type="submit" class="btn btn-block">Send</button>
</div>
</form>
</div>
In the other hand, the javascript:
function regFeedback() {
var name=document.getElementById('feedbacker').value;
var mail=document.getElementById('feedbackemail').value;
var feed=document.getElementById('feedback').value;
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
$(document).ready(function() {
$("form").remove();
$(".feedstatus").removeClass("hidden");
$(".feedbacker").text(name);
alert("Mensaje recibido. Gracias");
});
}
};
xmlhttp.open("GET","https://page.php?name="+name+"&email="+mail+"&feedback="+feed,true);
xmlhttp.send();
}
The data arrive to the data base, but the callback event where verifies: "if (this.readyState==4 && this.status==200) {" looks like don't work. I'm new in this, but i made it work well. But from a moment editing to another, something is wrong :/