Why this simple example does not work?

Why this simple example does not work?

savilasavila Posts: 1Questions: 1Answers: 0
edited February 2017 in Free community support

Hello,

I'm not able to make this simple example works. The datatable below is using the server of datatables.net to load json data, but nothing is loaded. What I am doing wrong? Thank you in advance.

<!DOCTYPE html>
<html><head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">  
    
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
    <title>PRUEBA</title>
    
    <script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>  
    
    <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> 
    
    <script type="text/javascript" class="init">
    
$(document).ready(function() {
    $('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "https://datatables.net/examples/server_side/scripts/server_processing.php"
    } );
} );

    </script>
</head>

<body>
    
    <table id="example" class="display" width="100%" cellspacing="0">
        <thead>
            <tr>
                <th>First name</th>
                <th>Last name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>First name</th>
                <th>Last name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
    </table>
    
</body></html>

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,850Questions: 1Answers: 10,519 Site admin
    Answer ✓

    Looks like you are trying to load the Ajax data off my server, which your browser (and my server) will reject for security reasons. You need to have your own Ajax data source (or enable CORS on the server, which I haven't done).

    Allan

This discussion has been closed.