Why my uWSGI server doesn't send response to Datatables request?

Why my uWSGI server doesn't send response to Datatables request?

burakkilicburakkilic Posts: 10Questions: 0Answers: 0
edited July 2012 in General
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

Replies

  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    Have you looked in the server's error log?
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    No errors. I also tried JSONP

    [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]
  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    What is the server responding with - use Firebug on Inspector to see.
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    edited July 2012
    Server is not responding. It is waiting and finally aborting.
  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    Perhaps an infinite loop or something? You'll need to add some debug code to your server-side script to find out what it is doing.

    Allan
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    the same code in my localserver is working, and gives 200 OK with a JSON response. But the cross server doesn't respond.
  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    > cross server

    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
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    Yes I did that, take a look at my first comment please.
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    Strange.

    "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.
  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    edited July 2012
    > http://datatables.net/release-datatables/examples/server_side/jsonp.html seems to be wrong.

    In what way? The example loads data into the table just fine for me - is it not for you?

    Allan
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    No;

    "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.
  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    edited July 2012
    I don't understand - in what way does my example not work? As I say, looking at the page in my browser I can see it working.

    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.
  • burakkilicburakkilic Posts: 10Questions: 0Answers: 0
    edited July 2012
    I tried the JSONP request in a REST client.
    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.
  • allanallan Posts: 63,305Questions: 1Answers: 10,433 Site admin
    Can you give me a link to the page please. I think that's the only way I'll be able to offer much help here.

    Allan
This discussion has been closed.