sabato 4 agosto 2012
Intercettare form con AJAX prima dell'invio
$(document).ready(function() {
$("#tastosubmit").click(function(e) {
// blocca ogni azione
e.preventDefault();
// cattura un valore del'input
var cod=$("[name='codice']").val();
// esegue la richiesta ajax al file specifico
$.ajax({
crossDomain: true,
url : "http://www.sito.org/leggidatabase.php?cf="+cod,
type: "GET",
success : function (data,stato) {
// se c'e' una risposta
if(data.responseText) {
$("#nomeform").submit();
return true;
// senno' non invia la form
} else {
alert("Utente non registrato");
return false;
}
},
error : function (richiesta,stato,errori) {
alert("Errore: "+stato+richiesta.status+errori);
}
});
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento