1

我制作了搜索表单,并将其用作 ajax searchform

我有问题html(data),当我放它时,html(data)它会显示加载图像和表格,它也会加倍这是我的代码:

$(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);

      });
    }); 
  });

我将如何将结果放入页面中?

下面是我的html代码

<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 as $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>

正如你所注意到的,我将课程结果放在<tbody class="result></tbody>

4

0 回答 0