The server side set up as documented doesn't make ajax request.

The server side set up as documented doesn't make ajax request.

tliebermantlieberman Posts: 2Questions: 1Answers: 0

It will create the table but never make ajax request to server request. What's wrong with this?

The .js in a document ready state.

var propertyid = $('#propertyid').val();

$('#responses-table').DataTable( {
       "processing": true,
       "serverSide": true,
       "ajax" : "http://127.0.0.1:8080/app_dev.php/api/reputation/surveys/table/" + propertyid
    });

The html

<input id="propertyid" type="hidden" name="propertyid" value="{{ property.id }}" />
<table id="responses-table" class="table table-hover table-striped table-bordered table-responsive">
     <thead>
          <tr>
                <th>Name</th>
                <th>Email</th>
                <th>Source</th>
                <th>Overall Rating</th>
                <th>Comment (if any)</th>
          </tr>
       </thead>
        <tfoot>
            <tr>
                 <th>Name</th>
                 <th>Email</th>
                 <th>Source</th>
                 <th>Overall Rating</th>
                 <th>Comment (if any)</th>
             </tr>
          </tfoot>
</table>

Api is responding with correct json according to documentation when hit directly. Ajax request isn't being made

Answers

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    Are you loading the page from http://127.0.01:8080? If not, then you will be running into a cross domain protocol - which your browser should be warning you about in the console.

    If it isn't that, then we would need to be able access the page to be able to offer any help.

    Allan

  • tliebermantlieberman Posts: 2Questions: 1Answers: 0

    @allan I'm loading it from http://127.0.01:8000 the api is at :8080. The console isn't throwing any errors and I don't think loading from different ports would create a cors issue. ( need to check into that ) Even if I got an error that would be great. Will I able to set the header authorization bearer like I would in jquery ajax with datatables. Thanks for any help.

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    I think it process is a cross site issue in that case. Can you make the Ajax request if you don't use DataTables - i.e. just $.ajax(...)?

    Allan

This discussion has been closed.