php - ajax post in search -


i make search form , i'm using ajax searchform.

i have problems in html(data), when put html(data) display loading image , table double here's code:

$(document).ready(function(){     $("#loading").hide();     <?php $type_temp = (!empty($type)) ? 'company/' .$type:'company';?>     $("#search_id").click(function(){       $("#loading").show();       $.post("<?php echo url_for('/admsys_dev.php/' .$type_temp); ?>", $("#send_search").serialize(), function(data){         $(".result").html(data);        });     });    }); 

how put result page?

heres html code below

<div id="sf_admin_content">   <h2>company</h2><br />   <div style="margin-bottom:20px;">     <form id="send_search" action="" method="get">       <input type="text" name="search" placeholder="search: " value="<?php echo $search; ?>" />       <input id="search_id" type="button" value="search" />     </form>   </div>   <a href="<?php echo url_for('/admsys_dev.php/company/add'); ?>" class="add">add</a>   <div id="loading" style="margin-left:186px; margin-top:30px;">     <img alt="" src="/images/preloader_transparent.gif" />   </div>   <table class="location" cellspacing="0" style="width:500px;">     <thead>     <tr>       <th>id</th>       <th>name</th>       <th>description</th>       <th>photo</th>       <th>option</th>     </tr>     </thead>     <tbody class="result">       <?php foreach($company $x => $companies): ?>       <tr id="company<?php echo $companies->getid(); ?>" class="<?php echo ($x&1) ? 'even':'odd'; ?>">         <td align="right"><?php echo $companies->getid(); ?></td>         <td><?php echo $companies->getname(); ?></td>         <td><?php echo $companies->getdescription(); ?></td>         <td><a href="" target="_blank"><img alt="" src="/uploads/company/<?php echo $companies->getimagefull(); ?>" /></a></td>         <td align="right">           <a href="<?php echo url_for('company/edit?id=' .$companies->getid() )?>">              <img alt="edit" src="/images/pencil.png" />           </a>           <a href="#delete" title="delete" onclick="return godelete(<?php echo $companies->getid(); ?>)">              <img alt="delete" src="/images/delete.png" />           </a>         </td>       </tr>     <?php endforeach; ?>     </tbody>   </table> <?php $type_temp = (!empty($type))?'company/'.$type:'company';  $data = array(   'maxperpage' => $company->getmaxperpage(),   'lastpage' => $company->getlastpage(),   'nbresults' => $company->getnbresults(),   'curpage' => $curpage,   'linkpage' => '/admsys.php/company'.$type_temp. '?search'.$search ); include_partial('event/pager',$data); ?>  </div> 

as youve notice put class results in <tbody class="result></tbody>


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo