Unable to get property 'length' of undefined or null reference

Unable to get property 'length' of undefined or null reference

DarioCSDarioCS Posts: 2Questions: 2Answers: 0

Description of problem:
I have done a simple form that call a GET web service to charge the table and I want refresh the table changing the URL but I' doen't work ....
At $("#myTable").DataTable().ajax.url( ajUrl); I get
Error messages shown: Unable to get property 'length' of undefined or null reference

Can someone help me?
This is my code :
Thanks a lot for everyone

<!DOCTYPE html>
<HTML>
<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">

<HEAD><TITLE> T2 Compilati in collaudo</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/DataTables-1.10.20/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" type="text/css" href="/css/buttons.dataTables.min.css">
</HEAD>
<BODY>

Prograssivo Membro Libreria SRC Data Ora Motivazione Richiedente Action







<

script type="text/javascript" class="init">

$(document).ready(function() {
$('#myTable').DataTable( {
order:[[0 ,'asc']] ,
processing : true,
serversite : true,
paging : true ,
pageLength : 15,
scrollY : true,
scrollX : true ,
dom: 'Bfrtip',
buttons: [
'copy', 'excel', 'print'
] ,

    "ajax": {
"cache" : true,
"type": "GET",
"url": "https://mio.it/rest/WS/?request=lista  ",
"dataType": 'json',
"datasrc": 'data'
        },
"columns": [
            { "data": "progressivo" },
            { "data": "membro" },
            { "data": "libreriasrc" },
            { "data": "ora" },
            { "data": "data"},
            { "data": "motivazione" },
            { "data": "richiedente" }  ,
{
  "data": null,
  className: "center",
  "render": function (o) { return '<a href=./WS?membro=' + o.membro + '>' + 'Visualizza' + '</a>' }
}

]

} );

} );

$(function() { // ------------------------------------------------------- // // reload table // ------------------------------------------------------ // $("#form1").on("submit", function(event) { event.preventDefault(); event.stopPropagation(); var ajUrl="https://mio.it/rest/WS/?request=lista"; ajUrl=ajUrl+"&membro="+document.getElementById('membro').value; ajUrl=ajUrl+"&motivazione="+document.getElementById('motivazione').value; ajUrl=ajUrl+"&richiedente="+document.getElementById('richiedente').value; $("#myTable").clear(); $("#myTable").DataTable().ajax.url( ajUrl); $("#myTable").DataTable().ajax.reload(null , false ); }); });

</BODY>
</HTML>

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.