html - How to submit a form that is loaded using jquery -


i have file contain html form php , loaded file using jquery , when try submit form ,the form doesn't submit , , refresh page file contain form loaded disappear. files:

$(document).ready(function() {  $('#admin_profile').click(function () {         $('#main').load('profile_admin.php', null, function () {              $('#addtot').click(function () {                 $('#cont').load('add.php');             })      }); }); }) 

my form exist in add.php it's simple form

 <form method="post" >       <td><input name="title" type="text"></td>       <td><textarea name="cont"></textarea></td>       <input type="submit" name="sendmsg" value="send msg"> </form> 

and php exist in same file , mean form , php code

if(isset($_post['sendmsg'])){             $title=mysqli_real_escape_string($connect,$_post['title']);             $cont=mysqli_real_escape_string($connect,$_post['cont']);             if(empty($title) || empty($cont)) {                 echo "some fields empty";             }             else {                 $qr8=$connect -> query("insert msg(title,cont) values ('$title','$cont')") or die($connect->error);                 if($qr8) {                     echo "success";                 }             }         } 

what want when click on submit button want form submit , message success or fields empty show on same div file loaded,

i guess php showed in add.php. need change form to:

<form method="post" action="add.php">     ... </form> 

if form doesn't have action attribute, uses url of current document. when form loaded javascript, that's document did loading, not pulled from.


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -