当用户完成提交到acceptClass.php时,我需要有关如何重定向到页面的帮助,
到目前为止,我有这个:
$('#acceptButton').click(function() {
var myData = $('#data_field');
$.post("acceptClass.php",{
projectName : myData.attr("data_project"),
headMark : myData.attr("data_headmark"),
id : myData.attr("data_id")
});
});
我的模态是:
<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 name="reasonForRejection" id="reasonForRejection" class="form-control" placeholder="Reason for rejection" rows="2" 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>
我需要将其重定向到mainPage.php
答案 0 :(得分:2)
在你的html上尝试这个JS事件
onclick="javascript:window.location.href='mainPage.php';"
示例:
<button onclick="javascript:window.location.href='mainPage.php';">Redirect</button>
更新2:
试试这个
echo '<button type="button" name="acceptButton" id="acceptButton" class="btn btn-success" onClick="javascript:window.location.href=\'mainPage.php\';">Confirm PASS!</button>';
答案 1 :(得分:1)
你需要额外参数&#39;回调&#39; :
$('#acceptButton').click(function() {
var myData = $('#data_field');
$.post("acceptClass.php", {
projectName : myData.attr("data_project"),
headMark : myData.attr("data_headmark"),
id : myData.attr("data_id")
}, function callback(result) {
// ... process result if need
// then redirect...
window.location = 'your page url'
});
);
答案 2 :(得分:1)
$('#acceptButton').click(function() {
var myData = $('#data_field');
$.post("acceptClass.php",{
projectName : myData.attr("data_project"),
headMark : myData.attr("data_headmark"),
id : myData.attr("data_id")
});
window.location.href="url";
});
只需在您的函数中使用默认的javascript。