在另一页上更新查询并将按钮设置为禁用

时间:2014-05-20 04:21:28

标签: php ajax twitter-bootstrap modal-dialog

我对ajax和modal有疑问。我需要做的是,当用户单击提交按钮时,它应该设置禁用按钮并将值发送到另一页以更新数据库。但我的方法是使用模态。

我的模态代码是这样的,

<div class="modal fade" id="qcRejectModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
              <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">QC <font color="CC0000"><b>REJECT</b></font> Confirmation Window</h4>
                  </div>
                  <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                              This is the confirmation window to PASS all the Quality Control for, <br/><br/>
                              PROJECT : <b>'.$row['PROJECT_NAME'].'</b>
                              HEADMARK : <b>'.$row['HEAD_MARK'].'</b>
                              ID : <b>'.$row['ID'].'
                            </div>
                        </div>
                    </div><br/>
                    <div class="row">
                        <div class="col-md-12">
                          <div class="form-group">
                            <textarea class="form-control" placeholder="Reason for rejection" rows="2" name="rejectionreason" id="rejectionreason" required></textarea>
                          </div>
                        </div>
                    </div>
                  </div>
                  <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <button type="button" name="rejectbutton" id="rejectbutton" class="btn btn-danger">Confirm REJECT!</button>
                  </div>
                </div>
                </div>
              </div>
            </div>

因此,在此代码中,当用户单击按钮时,

echo "<input type='hidden' data_project='$row[PROJECT_NAME]' data_headmark='$row[HEAD_MARK]' data_id='$row[ID]'></input>";
echo '<button type="button" name="qcreject" id="qcreject" class="btn btn-primary btn-danger btn- lg btn-block" data-toggle="modal" data-target="#qcRejectModal"> 
                <span style="font-size:35px"> '.$row['PROJECT_NAME'].' / <b>'.$_POST ["hm"].'</b>/'.$row['ID'].' ~ FAIL</span></button>';

执行并显示模态代码并等待用户在文本字段中输入注释,当用户单击REJECT按钮时,它应该通过

$row['PROJECT_NAME']$row['HEAD_MARK']$row['ID']和文本字段值(#rejectionreason)进入 processclass.php

processclass.php 上,这些变量将用于使用SQL查询更新数据库。

这是我的ajax的片段。

$('.rejectbutton').click(function() { 

        $.ajax({
            url: 'processclass.php',
            type: 'POST',
            data: ,
            success: function (result) {
              alert("Your data has been submitted");
            }
        });  

});

我在进程类上执行时遇到问题。这意味着将这些值传递给 processclass.php

1 个答案:

答案 0 :(得分:1)

$('.rejectbutton').click(function() { 
    $(this).attr('disabled','disabled');
        $.ajax({
            url: 'processclass.php',
            type: 'POST',
            data: {param_name: '<?php echo $param_value ?>'},
            success: function (result) {
              alert("Your data has been submitted");
            },
            complete: function(){
                $(this).removeAttr('disabled');
            }
        });  

});