jQuery DataTables를 사용하여 PHP에 ajax 호출에서 추가 매개 변수를 전달하는 방법은 무엇입니까?
내 코드는 다음과 같습니다.
$(document).ready(function() {
var dataTable = $('#student-grid').DataTable( {
responsive: {
details: {
renderer: function ( api, rowIdx ) {
var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
var header = $( api.column( cell.column ).header() );
return '<p style="color:#00A">'+header.text()+' : '+api.cell( cell ).data()+'</p>';
} ).toArray().join('');
return data ? $('<table/>').append( data ) : false;
}
}
},
processing: true,
serverSide: true,
ajax: "borrowedBookNew.php" // json datasource
} );
} );
새 매개 변수를 내 PHP 파일에 전달하고 새로운 결과를 얻고 싶습니다.
ajax
매개 변수를 객체 에 설정하여 추가 데이터를 전달할 수 있습니다 .
$('#student-grid').dataTable({
// ...
ajax: {
url: 'borrowedBookNew.php',
data: {
customField: 'customValue'
}
}
});
data
현재 데이터를 조작 할 수있는 객체로받는 함수를 전달할 수도 있습니다. 이는 페이지로드시 사용할 수없는 동적 데이터를 추가하는 데 특히 유용합니다.
출처 : http://datatables.net/examples/server_side/custom_vars.html
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다