ajax - Server side form don't work -
i have form in server side, witch downloads every page refresh, form has submit button. writing code below html catch submit handler, got fault.. how should it? friend told me had execute script submit catch when form loaded.. p.s. form loads js after button "edit" push.
$test variable holds html code buttons, divs etc. passing json. every row creates button. http://postimg.org/image/p1ugsfw4f/. @ same file
if(isset($_request['update'])){ $vardas = $_post['vardas']; $id = $_post['id']; $sqel = mysql_query("update `client_objects` set ob_name = '$vardas' ob_id = $id");}
i have post request.. in form after button "save changes" pushed, got redirected php file. isset works perfectly. want not open php file. better solution alarm.
$("#update").submit(function() { $.ajax({ type: 'post', url: 'demo/client_view_search_content.php', data: $("#formaclient").serialize(), success: function () { alert('success!') }, error: function () { alert('failure!') } }); return false;});
but code can't catch submit handler..
php file. ==>
$result = mysql_query("select * `client_objects`"); while($row = mysql_fetch_array($result)){ $records['data'][]= array( $row['ob_id'],$row['ptc_id'],$row['ob_name'],$row['ob_name'],$row['ob_name'],$row['ob_name'],$row['ob_name'],$row['ob_name'], $row['ob_name'], $test = "<div class='portlet-body'> <a class='btn default' data-toggle='modal' href='#$i'> edit </a> <div id='$i' class='modal fade' tabindex='-1' aria-hidden='true'> <div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'> <button type='button' class='close' data-dismiss='modal' aria-hidden='true'></button> <h4 class='modal-title'>responsive & scrollable</h4> </div> <form method='post' id = 'formaclient' action = 'demo/client_view_search_content.php' > <div class='modal-body'> <div class='scroller' style='height:300px' data-always-visible='1' data-rail-visible1='1'> <div class='row'> <div class='col-md-6'> <h4>some input</h4> <p> <input type='text' class='col-md-12 form-control' name = 'vardas' value = '$row[ob_name]'> </p> <p> <input type='text' class='col-md-12 form-control' name = 'id' value = '$row[ob_id]'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> </div> <div class='col-md-6'> <h4>some more input</h4> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> <p> <input type='text' class='col-md-12 form-control'> </p> </div> </div> </div> </div> <div class='modal-footer'> <button type='button' data-dismiss='modal' class='btn default'>close</button> <button type='submit' class='btn blue' name = 'update' id = 'update' >save changes</button> </div> </form> </div> </div> </div> </div> "); $i++; }if(isset($_request['update'])){ $vardas = $_post['vardas']; $id = $_post['id']; $sqel = mysql_query("update `client_objects` set ob_name = '$vardas' ob_id = $id");}
your question not 100% clear, think trying check user pressing submit button. if want know if user has pressed submit button can using value submit button gives you:
<input type="submit" name="submit" value="submit">
and in php script can check it's name in post/get array:
//$_post['submit'] contain value, set "submit" if(isset($_post['submit'])){ echo 'he pressed submit!'; }
Comments
Post a Comment