我有这个代码来绘制数据表,所以我尝试以JSON格式从服务器获取数据,但我需要发送数据:ajdi变量... 我的代码:
function drawMeh() {
$('#Meh').dataTable({
"ajax": "track_meh.php",
paging: false,
//"dom":' <"search"f><"top"l>rt<"bottom"ip><"clear">',
// end ,
"columns": [{
"data": "ID"}, {
"data": "datum"}, {
"data": "masina"},{
"data": "radnih_sati"},{
"data": "kolicina"},{
"data": "cena"},{
"data": "ukupno"},{
"data": "akcija"
}
],
"columnDefs": [
{
"targets": 7,
"data": "akcija",
"render": function(data, type, full, meta) {
// return data;
return '<div style="float:right;"><i class="fa fa-close"></i></div>';
}
},
{
"targets": [0],
"visible":false
}
]
});
};
如何将data: ajdi
发送到服务器以从track_meh.php获取正确的JSON数据?
答案 0 :(得分:2)
这是来自数据表1.10:
"ajax" : {
"url" : "track_meh.php",
"type" : "POST",
"data" : ajdi
},
以下是遗产:
$(document).ready( function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": " track_meh.php",
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": ajdi,
"success": fnCallback
} );
}
} );
} );
答案 1 :(得分:0)
类似这样的事情,http://prototypejs.org/learn/introduction-to-ajax
new Ajax.Request('/some_url', {
method: 'get',
parameters: {company: 'example', limit: 12}
});