Why my uWSGI server doesn't send response to Datatables request?
Why my uWSGI server doesn't send response to Datatables request?
burakkilic
Posts: 10Questions: 0Answers: 0
Everything is working in my server. I can get list of data with http://my_server_url/item/list/
But when datatables make the request below, my server doesn't responses. What can be the reason?
http://my_server_url/category/list/?callback=jQuery171038778996189120696_1342008564594&sEcho=1&iColumns=7&sColumns=&iDisplayStart=0&iDisplayLength=10&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&mDataProp_5=5&mDataProp_6=6&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=false&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=false&sSearch_4=&bRegex_4=false&bSearchable_4=false&sSearch_5=&bRegex_5=false&bSearchable_5=true&sSearch_6=&bRegex_6=false&bSearchable_6=false&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=false&bSortable_1=true&bSortable_2=false&bSortable_3=false&bSortable_4=true&bSortable_5=true&bSortable_6=false&_=1342008567583
But when datatables make the request below, my server doesn't responses. What can be the reason?
http://my_server_url/category/list/?callback=jQuery171038778996189120696_1342008564594&sEcho=1&iColumns=7&sColumns=&iDisplayStart=0&iDisplayLength=10&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&mDataProp_5=5&mDataProp_6=6&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=false&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=false&sSearch_4=&bRegex_4=false&bSearchable_4=false&sSearch_5=&bRegex_5=false&bSearchable_5=true&sSearch_6=&bRegex_6=false&bSearchable_6=false&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=false&bSortable_1=true&bSortable_2=false&bSortable_3=false&bSortable_4=true&bSortable_5=true&bSortable_6=false&_=1342008567583
This discussion has been closed.
Replies
[code] "bProcessing": true,
"bStateSave": true,
'sPaginationType' : 'full_numbers',
"bServerSide" : true,
"sAjaxSource" : "{% url get_category_list %}",
"fnServerData": function( sUrl, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
}[/code]
Allan
Ah - that's a key bit of information right there.
Browser's don't allow cross domain requests by default because of security issues. You need to look at using JSONP: http://datatables.net/release-datatables/examples/server_side/jsonp.html
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
}
Solved the problem. http://datatables.net/release-datatables/examples/server_side/jsonp.html seems to be wrong.
I have the data now but this time "aoColumnDefs" is not working. Rows are not coming.
In what way? The example loads data into the table just fine for me - is it not for you?
Allan
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
}
Worked. How I can use fnCallback here? I couldn't find any example. I cannot do anything with the data.
fnCallback is just a function that DataTables passed into fnServerData. It expects 1 parameter - the JSON coming back from the server (which is what jQuery's 'success' gives it.
Status Code: 200 OK
Cache-Control: max-age=0
Content-Language: en
Content-Type: application/javascript
Expires: Thu, 12 Jul 2012 06:23:18 GMT
Last-Modified: Thu, 12 Jul 2012 06:23:18 GMT
Vary: Accept-Language, Cookie
And RAW data has a JSON string.
But when I debug,
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": function(data, textStatus, jqXHR){
fnCallback(data);
alert(textStatus);
},
"error": function(msg){
fnCallback(msg.responseText);
},
"dataType": "jsonp",
"cache": false
} );
}
It comes to "error" block, not to the "success block".
And if I do "error":function(msg){
fnCallback(jQuery.parseJSON(msg.responseText));
},
it is working.
Allan