weixin_33726313 2013-04-22 03:14 采纳率: 0%
浏览 33

Ajax阻止我的表单提交

I have create a form for listing promotion in hotel, and I got ajax for search the promotion by check in and check out date. My promotion list have a submit button for booking.

When my page load, I just retrieve the promotion list from database with some random date, and I got search form for user use to filter the promotion by using ajax submit but when ajax trigger, the booking button is not submit.

Please help me. Thanks in advance

This is the ajax code:

$("#submitform").click(function(){
    $.ajax({
    data:$("#checkpromofrm").serialize(),
    url:'<?php echo '/'.APP_ROOT.'/promotion/checkpromotion'?>',
    type:"POST",
    success:function(respone){
    $('#hideform').html(respone);
    }
    });
    return false;
});

And this is my search form:

<form name="frmrate" action="" id="checkpromofrm">
    Check-in
    <input type="text" id="popupDatepicker"  style="width:100px;" name="txtstartdate" value="<?php $currentdate = date('d-M-Y', strtotime('1 days'));
                    echo $currentdate;
                }
            ?>"/>

    Check-out:
    <input type="text" id="elapsed"  style="width:140px;text-align:left; border:none;padding-left:0px;"  value="<?php $currentdate = date('d-M-Y', strtotime('2 days'));
                    echo $currentdate;
                }
            ?>" readonly="readonly" name="EndDateCheckRate"/>
    <input type="submit" id="submitform" value=" Check"  name="" />
</form>

This is my promotion list:

<form action="<?php echo '/' . APP_ROOT . '/'; ?>promotion/<?php echo $newroom['h_id']?>/hotel" method="post">
    <tr id="songlist">
        <td width="100">
            <img src="<?php echo '/'.APP_ROOTAdmin.'/'.$newroom['r_picpath'];?>" align="left"  />   
        </td>
        <td >
            <p><span style="color:#1A7CBC;font-weight:bold;">
                <input type="hidden" name="r_cat" value="<?php echo $newroom['r_cat']; ?>"  />
                <input type="hidden" name="brf" value="<?php $newroom['brf'] ?>"  />
                <?php echo $newroom['r_cat'];?> Single</span>
                <font><b>
                    <i><br />
                        <?php if($newroom['brf']=='0')
      { echo "Breakfast not included"; }
      else { echo "Breakfast included";}?>
                    </i></b>
                </font>
            </p>
        </td>


        <td align="center" valign="middle">
            <input type="hidden" name="txthid" value="<?php echo $HoDetail['h_id']; ?>" />
            <input type="hidden" name="txtrid" value="<?php echo $newroom['r_id']?>" />
            <input type="submit" class="bookbutton red" value="Book now" onclick="return check(num);" /><br />
            Only <?php echo $newroom['s_room']?> rooms left
        </td> 
    </tr>
</form>
  • 写回答

2条回答 默认 最新

  • 7*4 2013-04-22 04:10
    关注

    Your success callback function refers to an element that isn't appearing on your screen (at least not with the provided code. Also, you might want to verify that the URL you're generating with PHP is actually pointing to a valid URL.

    $("#submitform").click(function(){
      $.ajax({
        data:$("#checkpromofrm").serialize(),
        url:'<?php echo '/'.APP_ROOT.'/promotion/checkpromotion'?>',
        type:"POST",
        success:function(respone){
          $('#hideform').html(respone);  //<-- doesn't exist 
        }
      });
      return false;
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的