Multiple Post Using different param
Multiple Post Using different param
TheSys
Posts: 2Questions: 1Answers: 0
Hi..
i have datatable code like this:
$('#example').DataTable({
"paging": false,
"bInfo": false,
"searching": false,
"columnDefs": [
{ targets: 'no-sort', orderable: false }
],
"language": {
"processing": "Wait",
"emptyTable": "Ups..",
},
// Start POST
"processing": true,
"ajax": {
"url": "{{url('flights/dosearch')}}",
"type": "POST",
"data": {
_token: "{{ csrf_token() }}",
airline: "{{$airline->post_uri}}",
from: "{{Request::input('from')}}",
to: "{{Request::input('to')}}",
depart: "{{Request::input('depart')}}",
return: "{{Request::input('return')}}",
adult: "{{Request::input('adult')}}",
child: "{{Request::input('child')}}",
infant: "{{Request::input('infant')}}",
}
},
"columns": [
{ "data": null,
"render" : function ( data, type, full ) {
return "<ul class='no-bullet'><li><img src='{{asset('dist/airline')}}/"+full['segment'][0]['airline_code']+".png' width='50'><li><li><small>"+full['segment'][0]['fno']+"</small><li></ul>";
},
"sClass": "text-center"
},
{"data": null,
"render" : function ( data, type, full ) {
return "<ul class='no-bullet'><li>"+full['segment'][0]['from']+"<li><li><small>"+full['segment'][0]['std']+"</small><li></ul>";
},
"sClass": "text-center"
},
{ "data": null,
"render": function ( data, type, full ) {
var c_s = full['segment'].length;
if (c_s == 3) {
return "<ul class='no-bullet'><li>"+full['segment'][2]['to']+"<li><li><small>"+full['segment'][2]['sta']+"</small><li></ul>";
} else if (c_s == 2) {
return "<ul class='no-bullet'><li>"+full['segment'][1]['to']+"<li><li><small>"+full['segment'][1]['sta']+"</small><li></ul>";
} else {
return "<ul class='no-bullet'><li>"+full['segment'][0]['to']+"<li><li><small>"+full['segment'][0]['sta']+"</small><li></ul>";
}
},
"sClass": "text-center"
},
{ "data": null,
"render": function ( data, type, full ) {
var c_s = full['segment'].length;
if (c_s == 3) {
return "<ul class='no-bullet'><li>2 Transit<li></ul>";
} else if (c_s == 2) {
return "<ul class='no-bullet'><li>1 Transit<li></ul>";
} else {
if (full['segment'][0]['stop_over'] > 0) {
return "<ul class='no-bullet'><li>"+full['segment'][0]['stop_over']+" Stops<li></ul>";
} else {
return "<ul class='no-bullet'><li>NoneStop<li></ul>";
}
}
},
"sClass": "text-center"
},
{ "data": "nta",
"render": function ( data, type, full, meta ) {
return "<ul class='no-bullet'><li>Rp. "+tandaPemisahTitik(data)+"<li></ul>";
},
"sClass": "text-center"
},
{ "data": null,
"render": function ( data, type, full, meta ) {
// return "<a href='#' class='button tiny success'>Bookk Now</a>";
return '<form action="{{url('flights/booking')}}" method="POST"><input type="hidden" name="_token" value="{{ csrf_token() }}"><input type="hidden" name="depart_data" value='+JSON.stringify(full['segment'])+'><input type="hidden" name="depart_nta" value='+full['nta']+'><input type="hidden" name="depart_total" value='+full['total']+'><input type="hidden" name="depart_margin" value='+full['margin']+'><input type="hidden" name="searchinfo" value="{{$searchinfo}}"><button type="submit" class="button tiny success">Bookk Now</button></form>';
},
"sClass": "text-center"
},
],
"order": [[ 4, "asc" ]],
});
How i can loop the ajax post with different airline data and show in the same table id ?
Sorry for my bad english and fyi: iam newbie,,,
Thx Very much before..
This discussion has been closed.
Answers
Help me Please....
-__-
Do you mean that your template engine has multiple variables such as
Request::input('from')
(in an array for example)? If so, you will probably need to use whatever template engine you are using to perform the loop (since the Javascript known nothing about your template data).It might also be useful to keep in mind that
ajax.data
can be used as a function, which could be used if you were to dump the template data into a Javascript array.Allan