Dexlin Posted August 3, 2012 Share Posted August 3, 2012 Hi everyone, I would like to have a the comment system that i made submit the comment to the id on the current post( which works great), but i would like it to submit in the background using jquery. I have tried quiet a few answers i have found online but nothing works. Here is how my system works: The page example.php?id=$id gets the post from the db There is a form that show via a php function this form submits to postcomment.php (if the form is posted and the fields are not empty it say ok otherwise says Required fields can not be empty. I have the id form for the form and id comments for comments list. This is what jquery i have: $(document).ready(function() { $('#form').submit(function(e) { e.preventDefault(); var url = $(this).attr('action'); $.post(url, function(data) { if ( data = "Required fields can not be empty.") { alert("Required fields can not be empty."); } $('#comments').load(); }); }); }); When i submit the form with empty fields it alerts me with Required fields can not be empty. Great, but when entering the data in the fields the same message appears. So i dont know what i'm doing wrong. Any help with this will be great. Thanks Link to comment https://forums.phpfreaks.com/topic/266645-help-needed-posting-data-with-jquery-and-updating-a-element/ Share on other sites More sharing options...
jazzman1 Posted August 5, 2012 Share Posted August 5, 2012 What's actually your URL ? Link to comment https://forums.phpfreaks.com/topic/266645-help-needed-posting-data-with-jquery-and-updating-a-element/#findComment-1366937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.