javascript - Getting Clicked Edit Value Item to Another page using jquery/ajax -


mysql table name demo below listed values peter , john edit links

example

peter edit john  edit 

on clicking edit link i'm opening edit_name.php page. in edit_name.php i'm updating clicked edited value update button..

my requirement in edit_name.php should receive clicked name value

for example

if click on peter edit button should peter value in edit_name.php file , if click on john edit button should john value in edit_name.php etc..

please me in getting value of clicked in edit_name.php file

php code

<div> <?php      $sql="select * demo";     $data = $con->query($sql);     if($data->num_rows > 0)     {         while($row = $data->fetch_array(mysql_assoc))         {             $str = ""      ?>     <div class="show_edit_page">         <div>             <?php echo $row['name'];?>             <a href="#" class="ajax_edit" data-id="<?php echo $row['id'];?>">edit</a>         </div>     </div>     <?php        }     } ?> </div> <div id="content"></div> 

jquery code

jquery code open edit_name.php file on clicking edit link

$('.show_edit_page').on('click','.ajax_edit',function(){     var id = $(this).data('data-id');     $('#content').load('edit_name.php'); }); 

you give name url parameter load url:

('.show_edit_page').on('click','.ajax_edit',function(){   var id = $(this).attr('data-id');   $('#content').load('edit_name.php?name='+id);  }); 

then catch name parameter in edit_name.php file with:

$thename = $_request('name'); 

that should do...

also .data replace .attr on line 2


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -