dtdvlazd56637 2012-07-30 21:31
浏览 22
已采纳

jq_link_to_remote提交表单

How can I submit a form via POST with jq_link_to_remote and update the div?

testSuccess.php

 <div id="list">
 <form name="list" action="<?= url_for('shoppinglist/update'); ?>" method="post">
 .
 //some input text.
 .
 <?php
 function addlink() {

$linkname = "+";
 return jq_link_to_remote($linkname, array(
    'update' => 'list',
    'url' => 'shoppinglist/update',
    'data' => 'list', //this might be the problem.
    'loading' => jq_visual_effect('fadeIn', '#indicator'),
    'complete' => jq_visual_effect('fadeOut', '#indicator'),
    'method' => 'post',
 ));

}
echo addlink();
?>
<INPUT TYPE="button" VALUE="Cart" onClick="submitForm()">
</form>
</div>

Update

When I use this:

<?php
echo form_remote_tag( array(
'url'      => '@shoppinglist/update', // even when I don't type "@“
'update'   => 'list',
'loading'  => jq_visual_effect('fadeIn', '#indicator'),
'complete' => jq_visual_effect('fadeOut', '#indicator'),
 ));
 ?>

Error: Call to undefined function form_remote_tag()

When I use this:

function addlink() {

$linkname = "+";
 return jq_form_remote_tag($linkname, array(
     'url' => '@shoppinglist/update', // even when I don't type "@“
    'update' => 'list',
    'loading' => jq_visual_effect('fadeIn', '#indicator'),
    'complete' => jq_visual_effect('fadeOut', '#indicator'),
    'method' => 'post',
 ));

}
//I just echo a link!
echo  addlink();

Error: Notice: Undefined index: url in ... JQueryHelper.php line 353 and 410

  • 写回答

1条回答 默认 最新

  • dqr91899 2012-07-31 07:18
    关注

    Why don't you use jq_form_remote_tag instead?

    <?php echo jq_form_remote_tag(array(
      'url'      => 'shoppinglist/update',
      'update'   => 'list',
      'loading'  => jq_visual_effect('fadeIn', '#indicator'),
      'complete' => jq_visual_effect('fadeOut', '#indicator'),
    )) ?>
    

    I don't get the difference between addlink and submitForm ?

    edit:

    Well, you should set your template like that

    <div id="list">
      <?php echo jq_form_remote_tag(array(
      'url'      => 'shoppinglist/update',
      'update'   => 'list',
      'loading'  => jq_visual_effect('fadeIn', '#indicator'),
      'complete' => jq_visual_effect('fadeOut', '#indicator'),
      )) ?>
    
        //some input text.
    
        <input type="submit" value="Cart" />
      </form>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测