Uncaught TypeError: Cannot read property 'length' of undefined?
Uncaught TypeError: Cannot read property 'length' of undefined?
yaharga
Posts: 2Questions: 1Answers: 0
Alright, so, my JSON is too long to post on here, so, I'll just post the AJAX call and would like to ask what is wrong with it?
$('#MainContentPlaceHolder_business_return_flights').dataTable({
"ajax": {
"url": "Browse.aspx/GetBusinessFlights",
"type": "POST",
"contentType": "application/json; charset=utf-8",
"dataType": "json"
}
});
Also, I was wondering if I could pass data into the AJAX call. I couldn't do it, no matter how many different ways I tried.
Here's a link to more details of my problem: http://stackoverflow.com/questions/24007470/how-to-pass-ajax-data-in-datatables-jquery-plugin/
This discussion has been closed.
Answers
You can absolutely pass data into the AJAX call, information can be found at http://datatables.net/reference/option/ajax (or more specifically at http://datatables.net/reference/option/ajax.data).
As far as your original question goes, does the AJAX call get to the server where GetBusinessFlights is defined? The impression I got from your stack overflow post is that it isn't and the call is failing immediately.
Hi, first of all, thank you so much for replying! Also, I apologize for the confusion.
My question on Stackoverflow was regarding the data, not the JSON.
My problem essentially is that I am returning the JSON, and I am getting an error. Is my AJAX call wrong? Is my JSON syntax incompatible with the plugin? What's the right way to do it?
You can find more details for it here: http://stackoverflow.com/questions/24021259/datatables-uncaught-typeerror-cannot-read-property-length-of-undefined?
If you're getting Json back than I'd imagine your AJAX call is correct, I don't see anything wrong with it. I'd implement the success function that the stack overflow person showed and see if it hits there with the data. If it does without an error, you know that it has to do with reading the JSON and not something further up the pipeline. If that's the case than you might want to look into http://datatables.net/reference/option/ajax.dataSrc.