On ajax error: fnCallback for datatables 1.10

On ajax error: fnCallback for datatables 1.10

babablacksheepbabablacksheep Posts: 41Questions: 23Answers: 0
edited July 2014 in Free community support

Previously I was using fnCallback if ajax error happened, in fnCallback I just used to return
empty array.
How Can I do same in datatables 1.10 so that on ajax error , I set table`s data empty and hide processing div as well, this was very easy with fncallback?

        "fnServerData": function (sSource, aoData, fnCallback) {
              $.ajax({
                "type": "GET",
                "url": sSource,
                "success": function (json) {
                 
                },
                "error": function () {
                  fnCallback({
                    "data": []
                  });
                }
              });
            }

Now I am using datatables 1.10

  table.dataTable({
    //http://datatables.net/reference/option/
    "ajax": {
      "url": "user.json",
      "type": "POST",
      "dataSrc": function (json) {
        return json.data;
      },
      "error": function () {
        var data = {
          "data": []
        };
        return data ;
      }
    },
  });

This question has an accepted answers - jump to answer

Answers

  • babablacksheepbabablacksheep Posts: 41Questions: 23Answers: 0
    edited July 2014

    Hello,
    I see that fnServerData , sServerMethod , sAjaxSource and sAjaxDataProp are still available in datatables 1.10 . Are these going to be deprecated in future ? if not why are these not included in new documentation

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    edited July 2014 Answer ✓

    Are these going to be deprecated in future ?

    They will be removed in v2 - but development for that hasn't started yet, and likely won't for a long time to come.

    if not why are these not included in new documentation

    Because the new style camelCase syntax is preferred in the new documentation and I didn't want to confuse things by showing duplicate functionality using different names.

    How Can I do same in datatables 1.10 so that on ajax error

    Use ajax as a function to make an Ajax call as you were before.

    Allan

This discussion has been closed.