doutuobao4004 2014-06-17 07:13
浏览 28

是否可以使用AJAX()包含php文件? 在JQM移动表格中

I have a form page for a mobile website . In my desktop version I was including some php files that contains some extra form elements . It looked something like this .

<div id="DIVC3" class="divs_details">
    <?php include(dirname(__FILE__)."/cat3.tpl.php")?>
</div>
<div id="DIVC4" class="divs_details">
    <?php include(dirname(__FILE__)."/cat4.tpl.php")?>
</div>
<div id="DIVC5" class="divs_details">
    <?php include(dirname(__FILE__)."/cat5.tpl.php")?>
</div>
<div id="DIVC6" class="divs_details">
    <?php include(dirname(__FILE__)."/cat6.tpl.php")?>
</div>
<div id="DIVC8" class="divs_details">
    <?php include(dirname(__FILE__)."/cat8.tpl.php")?>
</div>
<div id="DIVC9" class="divs_details">
    <?php include(dirname(__FILE__)."/cat9.tpl.php")?>
</div>
<div id="DIVC10" class="divs_details">
    <?php include(dirname(__FILE__)."/cat10.tpl.php")?>
</div>
<div id="DIVC11" class="divs_details">
    <?php include(dirname(__FILE__)."/cat11.tpl.php")?>
</div>
<div id="DIVC12" class="divs_details">
    <?php include(dirname(__FILE__)."/cat12.tpl.php")?>
</div>
<div id="DIVC13" class="divs_details">
    <?php include(dirname(__FILE__)."/cat13.tpl.php")?>
</div>
<div id="DIVC15" class="divs_details">
    <?php include_once(dirname(__FILE__)."/cat15.tpl.php")?>
</div>
<div id="DIVC16" class="divs_details">
    <?php include(dirname(__FILE__)."/cat16.tpl.php")?>
</div>
<div id="DIVC17" class="divs_details">
    <?php include(dirname(__FILE__)."/cat17.tpl.php")?>
</div>
<div id="err_desc" style="visibility:hidden; display:none;">
    <?php
    $long_desc=strlen($t_POST['im_desc']);
    if ($long_desc>0 && $long_desc<15) {
        ?>
        <span style="color:#FF0000;font-weight:bold; font-size:12px"> <?=$this->translate->translate('ERR_DESC','nucleo','Descripción deficiente');?></span>
        <?php 
    }
</div>

But If i do this in mobile website it takes too long for the page to be loaded. So what I am thinking is like loading each page only when needed according to Onchange() event using Ajax() is it possible to include this way ??

Script

function includeFile(categoria) {
        if( categoria == (3))
{
        //here I want to include the file using Ajax()
}

}

Thanks & Regards

  • 写回答

1条回答 默认 最新

  • douzuan2814 2014-06-17 07:16
    关注

    Yes it is possible to load php with ajax. You only have to send your variables with Post or GET

    something like this with jquery ajax:

    $.ajax({ type: "POST", url: "bla/cat15.tpl.php", data: { name: "John", location: "Boston" } }) .done(function( data) { $('#DIVC15').html(data); });

    评论

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题