TypeError: i is undefined

TypeError: i is undefined

testbakecatestbakeca Posts: 5Questions: 1Answers: 0

.));for(var i=Q(a.sAjaxDataProp)(b),f=0,g=i.length;f<g;f++)if(c){for(var e=[],h=0...

I'm trying to use the DataTable , when I try to read the JSON gives me this error

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • testbakecatestbakeca Posts: 5Questions: 1Answers: 0

    Hello I understand what does not work .
    WHEN I use an Object That returns the JSON gives me this:
    {"success":1,"code":200,"messages":[],"content":{"sEcho":1,"iTotalRecords":10,"iTotalDisplayRecords"
    :30,"aaData":[{"id":1,"name":"ffff","vuoto":"wwww"},{"id":2,"name":"ffff","vuoto":"wwww"}]},"follow"
    :null}

    if json_encode use it all works perfectly, and me from this
    {"sEcho":1,"iTotalRecords":10,"iTotalDisplayRecords"
    :30,"aaData":[{"id":1,"name":"ffff","vuoto":"wwww"},{"id":2,"name":"ffff","vuoto":"wwww"}]}

    there is a way to make it work with the first json ?

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    You would need to use ajax as a function and make your own $.ajax call. Then pass json.content to the callback function.

    Allan

  • testbakecatestbakeca Posts: 5Questions: 1Answers: 0

    I am using DataTable 1.9 .
    I can use fnserverdata ?
    how can I do ?

  • testbakecatestbakeca Posts: 5Questions: 1Answers: 0

    "fnServerData": function( sUrl, aoData, fnCallback ) {
    $.ajax({
    "url": sUrl,
    "data": aoData,
    "success": function (json) {

                                var iTotalRecs = json.content['iTotalRecords'];
    
                                alert(iTotalRecs);
    
                                fnCallback(json);
                            },
                            "dataType": "json",
                            "cache": false
                        });
                    }
    

    I did so , alert the press the right result , how do I pass the result to datatable ?

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin
    Answer ✓

    fnCallback( json.content ) as I suggested above looks to be the way to do it.

    Allan

  • testbakecatestbakeca Posts: 5Questions: 1Answers: 0

    Thanks , it works :)

This discussion has been closed.