Im trying to integrate a comment system using jquery into my project but it doesn't work I need some help finding where the error could be:
javascript: <script type="text/javascript"> $(document).ready(function() { jQuery('#newComment').after('<div id="error"></div>'); jQuery('#submit').after('<img src="http://192.168.0.5/flog/ loading.gif" id="loading" alt="loading..." />'); jQuery('#loading').hide(); var form = jQuery('#newComment'); var err = jQuery('#error'); var error = "error"; form.submit(function(evt) { if(form.find('#author')[0]) { if(form.find('#author').val() == '') { err.html('<span class="error">Enter Name</span>'); return false; } // end if if(form.find('#comment').val() == '') { err.html('<span class="error">Enter Comment</span>'); return false; } // end if jQuery(this).ajaxSubmit({ beforeSubmit: function() { jQuery('#loading').show(); jQuery('#submit').attr('disabled','disabled'); }, // end beforeSubmit error: function(request){ err.empty(); var data = request.responseText; err.html('<span class="error">'+ data[1] +'</span>'); jQuery('#loading').hide(); jQuery('#submit').removeAttr("disabled"); return false; }, // end error() success: function(data) { try { var response = jQuery("<ol>").html(data); if (jQuery(document).find('.commentlist')[0]) { jQuery('.commentlist').append(response.find('.commentlist li:last')); } else { jQuery('#respond').before(response.find('.commentlist')); } // end if if (jQuery(document).find('#comments')[0]) { jQuery('#comments').html(response.find('#comments')); } else { jQuery('.commentlist').before(response.find('#comments')); } // end if err.empty(); form.remove(); // REMOVE THIS IF YOU DON'T WANT THE FORM TO DISAPPEAR jQuery('#respond').hide(); err.html('<span class="success">Your comment has been added.</ span>'); jQuery('#submit').removeAttr("disabled"); jQuery('#loading').hide(); } catch (e) { jQuery('#loading').hide(); jQuery('#submit').removeAttr("disabled"); alert(error+'\n\n'+e); } // end try } // end success() }); // end ajaxSubmit() return false; }); // end form.submit() }); // end document.ready() </script> my form: <form id="newComment" action="http://192.168.0.5/flog/add.php" method="post"> Nombre <br /> <input name="author" type="text" class="texto" id="author" size="30" /> <br />Mensaje:<br /> <textarea name="comment" id="comment" cols="40" rows="8" class="texto" ></textarea> <br /> <input type="submit" name="submit" id="submit" class="boton" value="Agregar Comentario →" /> <input type="hidden" name="comment_postid" value="28" /> <input type="hidden" name="type" id="type" value="1" / > </form> my add.php: <?php require_once('config.php'); function fix($string, $mode = 'form') { if (get_magic_quotes_gpc() == 1) { return $string; } else { return mysql_real_escape_string($string); } } $comment_time = time(); mysql_query("insert into `flogComments` set `comment_postid` = '".fix($_POST['comment_postid'])."', `comment_id` = '', `comment_type` = '".$_POST['type']."', `comment_date` = '$comment_time', `comment_user` = '".fix($_POST['author'])."', `comment_text` = '".fix($_POST['comment'])."'"); // `email` = '".fix($_POST['email'])."', ?> When I submit the form it goes to add.php... it does add the comment but it seems to ignore my jquery code, I don't know what might be causing this I've test the simple code using jquery.form and it works but then when I add all my checks and effects to the form it doesn't do nothing.