您好,我希望能够向我在 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>