【问题标题】:ajax call issue in server side processing of datatables数据表的服务器端处理中的 ajax 调用问题
【发布时间】:2018-01-25 00:40:45
【问题描述】:

我正在处理数据表的服务器端。 但我面临一个 ajax 错误,稍后我会解释。首先,这是我的代码:

表格

<table id="call_analysis_basic_table" class="display" cellspacing="0" width="100%">
    <thead style="background-color:#4d7496;color:#fff;" id="table_head">
        <tr>
            <th> Column 1 </th>
            <th> Column 2 </th>
            <th> Column 3 </th>
            <th> Column 4 </th>
            <th> Column 5 </th>
            <th> Column 6 </th>
            <th> Column 7 </th>
            <th> Column 8 </th>
            <th> Column 9 </th>
            <th> Column 10 </th>
        </tr>
    </thead>
</table>

Javascript

$(document).ready(function() {
    var dataTable = $('#call_analysis_basic_table').DataTable({
    "processing" : true,
    "serverSide" : true,
    "iDisplayLength": 5,
    "order" : [],
    "sAjaxSource" : {
        url : "http://localhost:8050/phpservice/final.php",
        type : "POST"
    }
});

当我加载页面时,这个数据表请求开始了,它创建了一个 url ih 浏览器网络设置。这是这段代码生成的网址:

http://localhost:8050/webapp/[object%20Object]?sEcho=1&iColumns=10&sColumns=%2C%2C%2C%2C%2C%2C%2C%2C%2C&iDisplayStart=0&iDisplayLength=5&mDataProp_0=0&sSearch_0=&bRegex_0=false&bSearchable_0=true&bSortable_0=true&mDataProp_1=1&sSearch_1=&bRegex_1=false&bSearchable_1=true&bSortable_1=true&mDataProp_2=2&sSearch_2=&bRegex_2=false&bSearchable_2=true&bSortable_2=true&mDataProp_3=3&sSearch_3=&bRegex_3=false&bSearchable_3=true&bSortable_3=true&mDataProp_4=4&sSearch_4=&bRegex_4=false&bSearchable_4=true&bSortable_4=true&mDataProp_5=5&sSearch_5=&bRegex_5=false&bSearchable_5=true&bSortable_5=true&mDataProp_6=6&sSearch_6=&bRegex_6=false&bSearchable_6=true&bSortable_6=true&mDataProp_7=7&sSearch_7=&bRegex_7=false&bSearchable_7=true&bSortable_7=true&mDataProp_8=8&sSearch_8=&bRegex_8=false&bSearchable_8=true&bSortable_8=true&mDataProp_9=9&sSearch_9=&bRegex_9=false&bSearchable_9=true&bSortable_9=true&sSearch=&bRegex=false&iSortingCols=0&_=1502908112765

此 url 将所有参数发送到处理服务器端处理的所需页面。但是 http://localhost:8050/webapp/ 之后的 url 存在问题。我不知道我的 URL 中的这个 [object%20Object] doinhg 是什么,我在调用中明确提到了 api url http://localhost:8050/phpservice/final.php

我认为除此之外一切都很好。希望如此 !! 我没有分享我的 php 代码,因为 php 代码没有任何问题,服务器端工作正常

知道为什么这个 url 的行为像这样而不是像预期的那样吗??

【问题讨论】:

  • 您提供的代码并未创建该网址。 DataTables 不会神奇地将 /webapp/ 添加到它前面并省略 phpservice/final.php
  • [object%20Object] 是他传入的 javascript 对象的字符串表示形式,而不是数据表所期望的字符串。
  • 你们能告诉我为什么要附加 URL 吗?

标签: javascript ajax datatable server-side


【解决方案1】:

sAjaxSource 不是一个对象。仅将 URL 作为字符串传递。 如果需要使用 POST,设置 sServerMethod: "POST"

【讨论】:

猜你喜欢
  • 2020-12-22
  • 1970-01-01
  • 2015-12-22
  • 1970-01-01
  • 2014-10-06
  • 1970-01-01
  • 2012-11-28
相关资源
最近更新 更多