jquery has a great function to serialize forms, that also allows you to respond on the server response if(response).
BUT! it ignores all inputs with are flagged “disabled”
[cc lang=”html” escaped=”true” width=”550″]
[/cc]
if you need input fields that a user can not edit use: “readonly”
[cc lang=”html” escaped=”true” width=”550″]
[/cc]
example for jquery serialize form function
[cc lang=”js” escaped=”true” width=”550″]
/* read all input fields of a form, assemble target.php?key=value url and submit via jqxhr request. */
function submitForm(form) {
var data = null;
var url = “backend.php?”;
url += $(form).serialize();
var jqxhr = $.post(url, data, function(response, status, xhr) {
if (response) {
if (status == “success”) {
var result_array = response.split(‘,’);
if (result_array[1] == “mail send successfully”) {
alert(“Vielen Dank für Ihre Anfrage, diese wurde erfolgreich verschickt!”);
window.open(“http://domain.de/”,”_self”);
}
if (result_array[1] == “mail send failed”) {
alert(“Es ist ein technischer Fehler beim verschicken der Anfrage aufgetreten, bitte Kontaktieren Sie uns über das Impressum, Danke!”);
}
if (result_array[1] == “domain not valid”) {
alert(“Ihre Mail-Adresse “+result_array[0]+” scheint keine gültige Domain zu sein.”);
}
}
}
});
}
[/cc]
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!