This code lets you do something if the response back is of a certain length.
In this case if the database already had a tag called that, the response was shorter than if it had not. Therefore it would stop an action happening.
Cant figure out how to stop it if a string was actual text! (usually simple).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{ $.post("addtag.php", $("#newtag").serialize(), function(data) { // alert(data.length); if(data.length == 22) { } else { var myOptions = { val1 : x.value }; $.each(myOptions, function(val, text) { $('#oldtag').append( new Option(text,val) ); }); } $("#formResponse").html(data); } ); return false; }//end if |