Ajax can not find a php page that gets its data from a database

Ajax can not find a php page that gets its data from a database

draguladragula Posts: 2Questions: 1Answers: 0

So I am a rookie and I ran across this great stats plugin for my game server that is no longer supported. It records events that happen in game to a database and also has web pages to display this data. Most of the program works and everything is recording to my database properly. The game server/database and webserver are all on the same windows machine and the webserver is hosted with IIS 8.5. The issue is, 2 of the php pages are returning a datatables warning Ajax error tn/7 (404 not found) The thing is, the original author whom I can not get in touch with still has a demo site that is fully functioning. I have spent the last 2 days trying to compare my info to his and granted I now know 1000x more than I did prior, I still feel like I am miles away. It is hard to learn how to say phrases in French when your in India (this is how I feel)

I have ran the debugger on my page and the working demo site for comparison.

My site is http://tf2.cavemantutorials.com/stats/items.php and debug code is uziref
demo site http://thepit.servegame.com/stats/items.php and debug code is inotib

Note that items.php and players.php return the same error. Every other php page works just fine and displays the data in the tables.

Now the scripts that call onto the server_processing.php page are the 2 that error. The code in items.php looks like this:

<script>
  $(document).ready(function() {
    
    var items = $('#log').DataTable( {
      "processing": false,
      "serverSide": true,
      "ajax": "inc/server_processing.php?type=allitems",
      "pagingType": "full",
      //"dom": "<lf<t>pi>",
      "columns": [
        { "data": "time",
          "searchable": false,
          "render": function ( data, type, full, meta ) {
            return '<h5 style="display: block;margin-left: auto;margin-right: auto;">'+data+'</h5>';
          }
        },
        { "data": "index", "visible" : false, "searchable": false },
        { "data": "name",
          "render": function ( data, type, full, meta ) {
            return '<h5 style="display: block;margin-left: auto;margin-right: auto;">'+data+'</h5>';
          }
        },
        { "data": "image",
          "searchable": false,
          "render": function ( data, type, full, meta ) {
            return '<img style="display: block;margin-left: auto;margin-right: auto;" width=75px height=75px src="'+data+'">';
          }
        },
        { "data": "method_text",
          "render": function ( data, type, full, meta ) {
            return '<h5 style="text-align:center;display: block;margin-left: auto;margin-right: auto;">'+data+'</h5>';
          }
         },
        { "data": "quality_text",
          "render": function ( data, type, full, meta ) {
            return '<h5 style="text-align:center;display: block;margin-left: auto;margin-right: auto;">'+data+'</h5>';
          }
         },
        { "data": "quality_color", "visible" : false, "searchable": false },
        { "data": "class",
          "render": function ( data, type, full, meta ) {
            return '<h5 style="text-align:center;display: block;margin-left: auto;margin-right: auto;">'+data+'</h5>';
          }
         },
        { "data": "slot",
          "render": function ( data, type, full, meta ) {
            return '<h5 style="text-align:center;display: block;margin-left: auto;margin-right: auto;">'+data+'</h5>';
          }
         },
         { "data": "type", "visible" : false, "searchable": true },
      ],
      "order": [[0, 'desc']],
      "createdRow": function ( row, data, index ) {
        $('td', row).eq(2).css('background-color',data.quality_color);
      }
    });
    $('#log tbody').on('click', 'tr', function () {
      $('#modal').modal('show');
      $.ajax({
        type: "GET",
        url: "inc/getitems.php",
        data: 'id=' + items.cell(this, 1).data(),
        success: function(msg){
          $('#modal').html(msg);
        }
      });
    });
    $('#log tbody').on('click', 'tr', function () {
      items.search(items.cell(this, 2).data()).draw();
      $('.dataTables_filter input').val(items.cell(this, 2).data());
    });
  });
  </script>

Also the script on players.php:

<script>
$(document).ready(function() {
    var players = $('#players').DataTable( {
        "processing": false,
        "serverSide": true,
        "ajax": "inc/server_processing.php?type=getplayers",
        "pagingType": "full",
        "columns": [
            { "data": "name" },
            { "data": "auth", "visible" : false },
            { "data": "kills" },
            { "data": "deaths" },
            { "data": "assists" },
            { "data": "kpd" },
            { "data": "kpm" },
            { "data": "playtime" },
            { "data": "disconnect_time" }
        ],
        "order": [[2, 'desc']]
    });
    $('#players tbody').on('click', 'tr', function () {
            window.location = "player.php?id="+players.cell(this, 1).data();
    });
});
</script>

Here is the bit of code each script points to in server_processing.php for players.php (there are more arrays and a return htmlentities

if (isset($_GET['type']) && $_GET['type'] == 'getplayers') {

    $table = 'playerlog';
    $primaryKey = 'kills';
     
    $columns = array(
        array(
            'db'        => 'name',
            'dt'        => 'name',
            'formatter' => function( $d, $row ) {
                return htmlentities($d);
            }
        ),

Here is the code on server_processing.php for the items.php also more arrays for each with a return htmlentities

if (isset($_GET['type']) && $_GET['type'] == 'getitems') {

    $table = 'itemlog';
    $primaryKey = 'auth';
     
    $columns = array(
        array(
            'db'        => 'itemlog.auth',
            'dt'        => 'auth',
            'field'     => 'auth'
        ),

If you visit my page and click on any other tab like "top 10" "actions" "weapons" "maps" and view the source you will see that each of these php pages also has an ajax script calling other files in a different php page but it does it a little differently. As I said, I do not know enough about this to be able to explain any better. I know the server_processing.php link has a long query string for all of the different variables it displays. This is not an error on my part as on the plugin page for this, I have seen others mention the same data tables warning, plus it was pretty much a copy n paste to install this.

Sorry for the extremely long post but I ahve asked on several different sites and have not gotten any responses that ws of any help so I figured I would try here with a thorough explanation. At least this jouney has had me discover a new found past time! Cant wait to learn more.

Answers

  • draguladragula Posts: 2Questions: 1Answers: 0

    I was really hoping someone could at least steer me in the right direction with this. Anything would be greatly appreciated.

This discussion has been closed.