こんにちは、Ajaxで送信されるデータにデータを追加できるようにしたいと思います。
<script type="text/javascript">
$(document).ready(function() {
//http://www.datatables.net
$('#dataTable').dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Project/GetDataTables2",
"aoColumns": [
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true }
],
"fnServerData": function(url, data, callback) {
$.ajax({
"url": url,
"data": data, //I want to add additional data from here like the QueryString DPID
"success": callback,
"contentType": "application/x-www-form-urlencoded; charset=utf-8",
"dataType": "json",
"type": "POST",
"cache": false,
"error": function() {
alert("DataTables warning: JSON data from server failed to load or be parsed. " +
"This is most likely to be caused by a JSON formatting error.");
}
});
}
});
});
</script>
私はやってみました:
data: data + "&moredata=" + morevalue
ただし、スクリプトエラーが発生し、URLに送信されません...助けてください!
編集1:
私は今、このDPIDがうまくいくようにそれを渡しますが、dtはそうではありません:
<script type="text/javascript">
$(document).ready(function() {
//http://www.datatables.net
$('#dataTable').dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Project/GetDataTables2",
"aoColumns": [
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true }
],
"fnServerData": function(url, data, callback) {
$.ajax({
"url": url,
"data": { DPID: "1", dt: data }, //I want to add additional data from here like the QueryString DPID
"success": callback,
"contentType": "application/x-www-form-urlencoded; charset=utf-8",
"dataType": "json",
"type": "POST",
"cache": false,
"error": function() {
alert("DataTables warning: JSON data from server failed to load or be parsed. " +
"This is most likely to be caused by a JSON formatting error.");
}
});
}
});
});
</script>