Sympathisant: Der Vollstaendigkeit wegen..

Beitrag lesen

Hai,

habe den Code nun wie besagt umgeschrieben. Jetzt klappt es wunderbar.

  
$(document).ready(function()  
{		  
	// validate input before submitting the form  
	$("form:last").submit(function(event) {  
  
		// deactivate submit button  
		$("#frm_submit").attr("disabled","disabled");  
				  
		var str = $(this).serialize(); // form parameters  
		  
		$.post("sources/ajax/registration_customer.php",   str ,  
				  function(json) {  
						var sthWrong = false;  
						$.each (	  
							json.items, function(i,item) {  
								if(item.state!="OK") {  
									sthWrong = true;  
								}  
								MarkFormField(item.field,item.state);  
							}  
						);	  
						if(sthWrong) {  
							$("#frm_submit").removeAttr("disabled"); // enable submit button again  
							return false;  
						} else {  
							InsertUser(str);  
						}  
				  }, "json" );  
  
		// finish (do not submit the form)  
		return false;  
	});  
});  
  
  
function InsertUser(myparams)  
{  
	$.ajax({  
		type: "POST",  
		url: "sources/ajax/insert_customer.php",  
		data: myparams,  
		success: function(msg) {  
			if(msg == 'OK') { // Message Sent? Show the 'Thank You' message and hide the form  
				$("form:last").fadeOut("slow",function() {  
					$("#registration_successfull").fadeIn("slow");  
				});	  
			}	  
			else {  
				$("form:last").fadeOut("slow",function() {  
					$("#registration_failed").fadeIn("slow");  
				});	  
			}							  
		}  
	});  
}  
  

Der jeweilige PHP-Code liefert mir nun mittels json_encode das entsprechende JSon-Objekt.

MfG,
Sympatisant

--
"If the future isn't bright, at least it is colorful"