Bootstrap Datatable binding issue The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEvent binding on dynamically created elements?How does data binding work in AngularJS?Javascript call() & apply() vs bind()?Not able to get response while calling ssl enabled restful wcf service using jquery ajax requestDelete rows in Datatable before destroyingCan't bind to 'ngModel' since it isn't a known property of 'input'Is there a callback for when an Angular DTOptionsBuilder ajax call finishes?Add nested datatable within child row of another datatableRefresh datatable after adding data?Datatable information being appended to a table in a modal dialog

Match Roman Numerals

Is every episode of "Where are my Pants?" identical?

How do spell lists change if the party levels up without taking a long rest?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Can each chord in a progression create its own key?

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

Are spiders unable to hurt humans, especially very small spiders?

Does Parliament need to approve the new Brexit delay to 31 October 2019?

What can I do if neighbor is blocking my solar panels intentionally?

Is there a writing software that you can sort scenes like slides in PowerPoint?

Solving overdetermined system by QR decomposition

Can I visit the Trinity College (Cambridge) library and see some of their rare books

Can withdrawing asylum be illegal?

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

Word for: a synonym with a positive connotation?

Would an alien lifeform be able to achieve space travel if lacking in vision?

Do working physicists consider Newtonian mechanics to be "falsified"?

Mortgage adviser recommends a longer term than necessary combined with overpayments

Why can't devices on different VLANs, but on the same subnet, communicate?

Why doesn't a hydraulic lever violate conservation of energy?

What information about me do stores get via my credit card?

What other Star Trek series did the main TNG cast show up in?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?



Bootstrap Datatable binding issue



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceEvent binding on dynamically created elements?How does data binding work in AngularJS?Javascript call() & apply() vs bind()?Not able to get response while calling ssl enabled restful wcf service using jquery ajax requestDelete rows in Datatable before destroyingCan't bind to 'ngModel' since it isn't a known property of 'input'Is there a callback for when an Angular DTOptionsBuilder ajax call finishes?Add nested datatable within child row of another datatableRefresh datatable after adding data?Datatable information being appended to a table in a modal dialog



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am creating a data table using the existing table .



here is my code :



Loaddata: function () 
var table = $('#main-table');
var row = "";
var count = 0;
$.ajax(
type: "GET",
url: apicall,
beforeSend: CommonJS.BeforeSendAjaxCall,
processdata: OPVConfig.ProcessData,
contentType: "application/json; charset=utf-8",

success: function (data) //getting object array
if (data !== null)

$.each(data.Data, function (key, val) //creating table from api responce
row = "<tr class=clickable - row data-href='/'" +
"<td scope=row>" + CommonJS.checkNull(val.containercode) + "</td>" +
"<td>" + val.Streetname + val.Housenumber + val.city + "</td> " +
"<td>" + CommonJS.checkNull(val.Zipcode) + "</td> " +

"<tr>";
$("#main-table").append(row); //append the row
);

$("#main-table").dataTable();


,
error: function (xhr, status, error)
//do error stuff here
,
complete: function ()

//do complete stuff here



);



Data fetching and table data populations are working correctly, but the datatable is not working, I got an error in console :




"Uncaught TypeError: Cannot read property 'length' of undefined"











share|improve this question



















  • 1





    your code does not include any "length" attribute that is tried to access. Can you add a call stack to the error?

    – ArSeN
    Mar 8 at 12:56

















0















I am creating a data table using the existing table .



here is my code :



Loaddata: function () 
var table = $('#main-table');
var row = "";
var count = 0;
$.ajax(
type: "GET",
url: apicall,
beforeSend: CommonJS.BeforeSendAjaxCall,
processdata: OPVConfig.ProcessData,
contentType: "application/json; charset=utf-8",

success: function (data) //getting object array
if (data !== null)

$.each(data.Data, function (key, val) //creating table from api responce
row = "<tr class=clickable - row data-href='/'" +
"<td scope=row>" + CommonJS.checkNull(val.containercode) + "</td>" +
"<td>" + val.Streetname + val.Housenumber + val.city + "</td> " +
"<td>" + CommonJS.checkNull(val.Zipcode) + "</td> " +

"<tr>";
$("#main-table").append(row); //append the row
);

$("#main-table").dataTable();


,
error: function (xhr, status, error)
//do error stuff here
,
complete: function ()

//do complete stuff here



);



Data fetching and table data populations are working correctly, but the datatable is not working, I got an error in console :




"Uncaught TypeError: Cannot read property 'length' of undefined"











share|improve this question



















  • 1





    your code does not include any "length" attribute that is tried to access. Can you add a call stack to the error?

    – ArSeN
    Mar 8 at 12:56













0












0








0








I am creating a data table using the existing table .



here is my code :



Loaddata: function () 
var table = $('#main-table');
var row = "";
var count = 0;
$.ajax(
type: "GET",
url: apicall,
beforeSend: CommonJS.BeforeSendAjaxCall,
processdata: OPVConfig.ProcessData,
contentType: "application/json; charset=utf-8",

success: function (data) //getting object array
if (data !== null)

$.each(data.Data, function (key, val) //creating table from api responce
row = "<tr class=clickable - row data-href='/'" +
"<td scope=row>" + CommonJS.checkNull(val.containercode) + "</td>" +
"<td>" + val.Streetname + val.Housenumber + val.city + "</td> " +
"<td>" + CommonJS.checkNull(val.Zipcode) + "</td> " +

"<tr>";
$("#main-table").append(row); //append the row
);

$("#main-table").dataTable();


,
error: function (xhr, status, error)
//do error stuff here
,
complete: function ()

//do complete stuff here



);



Data fetching and table data populations are working correctly, but the datatable is not working, I got an error in console :




"Uncaught TypeError: Cannot read property 'length' of undefined"











share|improve this question
















I am creating a data table using the existing table .



here is my code :



Loaddata: function () 
var table = $('#main-table');
var row = "";
var count = 0;
$.ajax(
type: "GET",
url: apicall,
beforeSend: CommonJS.BeforeSendAjaxCall,
processdata: OPVConfig.ProcessData,
contentType: "application/json; charset=utf-8",

success: function (data) //getting object array
if (data !== null)

$.each(data.Data, function (key, val) //creating table from api responce
row = "<tr class=clickable - row data-href='/'" +
"<td scope=row>" + CommonJS.checkNull(val.containercode) + "</td>" +
"<td>" + val.Streetname + val.Housenumber + val.city + "</td> " +
"<td>" + CommonJS.checkNull(val.Zipcode) + "</td> " +

"<tr>";
$("#main-table").append(row); //append the row
);

$("#main-table").dataTable();


,
error: function (xhr, status, error)
//do error stuff here
,
complete: function ()

//do complete stuff here



);



Data fetching and table data populations are working correctly, but the datatable is not working, I got an error in console :




"Uncaught TypeError: Cannot read property 'length' of undefined"








javascript ajax






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 12:55









Davide Casiraghi

496318




496318










asked Mar 8 at 12:01









Afsal cAfsal c

11




11







  • 1





    your code does not include any "length" attribute that is tried to access. Can you add a call stack to the error?

    – ArSeN
    Mar 8 at 12:56












  • 1





    your code does not include any "length" attribute that is tried to access. Can you add a call stack to the error?

    – ArSeN
    Mar 8 at 12:56







1




1





your code does not include any "length" attribute that is tried to access. Can you add a call stack to the error?

– ArSeN
Mar 8 at 12:56





your code does not include any "length" attribute that is tried to access. Can you add a call stack to the error?

– ArSeN
Mar 8 at 12:56












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062846%2fbootstrap-datatable-binding-issue%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062846%2fbootstrap-datatable-binding-issue%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown