Problem uploading a CSV file....

Problem uploading a CSV file....

Hayes7888Hayes7888 Posts: 9Questions: 2Answers: 0

Hi,

I have a page to upload a CSV to and then display data after the upload.

There is a strange problem that not all CSV files are working although they appear to be identical structures, column headers etc.

Apart from the column data itself, is there a difference between these 2 files?

payments.csv works fine but payments999.csv will not upload?

upload URL is www.spruceweb.net

Cheers,

spruceweb.net/payments.csv

spruceweb.net/payments.csv

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    I don't immediately see any differences between the two files. But the problem is not with Datatables. You are getting this error in the browser's console:

    jquery.dataTables.min.js:115 Uncaught TypeError: Cannot read property 'length' of null

    Which points to this line in your ajax success function:

    $('#shopify_payouts').DataTable().rows.add( jsonData ).draw();
    

    If you use the browser's debugger you will find when uploading payments99.csv the jsonData response is null. So if you look at the network inspector tool you will see that the form data is sent as CSV file:

    But the response is null:

    You will need to debug why the server is sending a null repsonse.

    Kevin

  • Hayes7888Hayes7888 Posts: 9Questions: 2Answers: 0

    Ok, thanks

    This may be bit too advanced for me to work out but I'll have a look into it

  • Hayes7888Hayes7888 Posts: 9Questions: 2Answers: 0

    Ok,

    As this line seems to be the issue, can I use a different way of doing it?

    $('#shopify_payouts').DataTable().rows.add( jsonData ).draw();
    
  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    You are getting this error:

    jquery.dataTables.min.js:115 Uncaught TypeError: Cannot read property 'length' of null

    From this line:

    $('#shopify_payouts').DataTable().rows.add( jsonData ).draw();
    

    The reason for the error is that the response data, jsonData, is null. The null response is from the server. You could use an if statement to check for null and skip that statement if the data is null to stop the error. But that won't solve the problem of why the server is responding with null instead of the CSV data.

    You will need to troubleshoot the server script to find out why the response is null.

    Kevin

This discussion has been closed.