当我点击编辑按钮时,我想用数组行重定向到页面。
$sQuery = " SELECT SQL_CALC_FOUND_ROWS " . str_replace(" , ", " ", implode(", ", $aColumns)) . " FROM $sTable $sWhere $sOrder $sLimit ";
$rResult = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
$sQuery = " SELECT FOUND_ROWS() ";
$rResultFilterTotal = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
$aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
$iFilteredTotal = $aResultFilterTotal[0];
$sQuery = " SELECT COUNT(" . $sIndexColumn . ") FROM $sTable ";
$rResultTotal = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
$aResultTotal = mysql_fetch_array($rResultTotal);
$iTotal = $aResultTotal[0];
while ( $aRow = mysql_fetch_array($rResult) ) {
$row = array();
for ( $i = 0 ; $i < count($aColumns); $i++ ) {
if ( $aColumns[$i] == "version" ) $row[] = ( $aRow[$aColumns[$i]] == "0" ) ? '-' : $aRow[$aColumns[$i]];
else if ( $aColumns[$i] != ' ' ) $row[] = $aRow[$aColumns[$i]];
}
$output['aaData'][] = array_merge($row, array('<a data-id="row-' . $row[0] . '" href="javascript:editRow(' . $row[0] . ');" class="btn btn-md btn-success">edit</a> <a href="javascript:removeRow(' . $row[0] . ');" class="btn btn-default btn-md" style="background-color: #c83a2a;border-color: #b33426; color: #ffffff;">remove</a>'));
}
// RETURN IN JSON
die(json_encode($output));
}
// ATW
if ( top.location.href != location.href ) top.location.href = location.href;
// Initialize datatable
$('#example').dataTable({
"aProcessing": true,
"aServerSide": true,
"ajax": "add.php?ajax"
});
// Save edited row
$("#edit-form").on("submit", function(event) {
event.preventDefault();
$.post("add.php?edit=" + $('#edit-id').val(), $(this).serialize(), function(data) {
var obj = $.parseJSON(data);
var tr = $('a[data-id="row-' + $('#edit-id').val() + '"]').parent().parent();
$('#edit-modal').modal('hide');
}).fail(function() { alert('Unable to save data, please try again later.'); });
});
});
// Edit row
function editRow(id) {
if ( 'undefined' != typeof id ) {
$.getJSON('add.php?edit=' + id, function(obj) {
$('#edit-modal').modal('show')
}).fail(function() { alert('Unable to fetch data, please try again later.') });
} else alert('Unknown row id.');
我想点击编辑按钮时在新页面中重定向。查看新页面中的数据而不是模态。请帮忙。我可以捐款。
直接在新页面中创建新网页,不要在模态上进行编辑。非常感谢你。
答案 0 :(得分:0)
嘿约翰史密斯,如果这是你的真名......嗯(¬_¬)
听起来像是要像这样重定向:
window.location.href = "http://stackoverflow.com";
或在按钮内单击
$('#some-html-tag-id').cl
.click(function() {
window.location.href = "http://stackoverflow.com";
});
这也许是对你的问题的一个很好的答案。 How to redirect to another webpage in JavaScript/jQuery?