jquery datatables Ajax-Error /http://datatables.net/tn/7

brqmpdu1  于 2023-11-17  发布在  jQuery
关注(0)|答案(4)|浏览(135)

下面请看我的问题:
我在我的MVC-Web-Appliation中使用了jquery数据表。当我只显示8列时,一切都正常。但是当我多显示1列时,我得到了ajax-error-message,请参见标题。
控制器工作正常,因为8列工作正常。下面是我的视图代码:

<script type="text/javascript">
    $(document).ready(function () {
        var table = $('#example').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "@Url.Action("List", "DFS_Akustik")",
            "columns": [
                { "data": "ID" },
                { "data": "MessID" },
                { "data": "KL_ID" },
                { "data": "MP_ID" },
                { "data": "LwLin50ss" },
                { "data": "LwLin63ss" },
                { "data": "LwLin80ss" },
                { "data": "LwLin100ss" },
                //{ "data": "LwLin125ss" },
            ],
        });
    });
</script>

字符串
你可以,最后一列是不活动的,然后:
http://ziehl-abegg.com/files/work.jpg
当我删除最后一列的//时,则:
http://ziehl-abegg.com/files/work_not.jpg
我该如何解决这个问题??请帮助我...我寻找一个解决方案,从星期一,一整天!!
谢谢
绿色蔬菜_77

33qvvth1

33qvvth11#

我有它,我的朋友们!非常好:-)
以下是解决方案:

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "scripts/post.php",
            "type": "POST"
        },
        "columns": [
            { "data": "first_name" },
            { "data": "last_name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
    } );
} );

字符串
我刚刚编辑了“ajax”。当你使用“type”“POST”时,它就能工作了。
非常感谢
绿色蔬菜_77

of1yzvn4

of1yzvn42#

早上好。这里的HTML /表格标题:

<div style="width: auto; height: 750px; overflow-x: auto; overflow-y: auto;">
    <table id="example" class="table display" cellspacing="0">
        <thead>
            <tr>
                <th>ID</th>
                <th>MessID</th>
                <th>KL_ID</th>
                <th>MP_ID</th>
                <th>LwLin50ss</th>
                <th>LwLin63ss</th>
                <th>LwLin80ss</th>
                <th>LwLin100ss</th>
                @*<th>LwLin125ss</th>*@
            </tr>
        </thead>
    </table>
</div>

字符串
服务器端的结果是好的,看:
http://ziehl-abegg.com/files/ServerSide.jpg
@Sippy.我不明白我们的第二个问题。
名称都是正确的,看第三张图片/链接.这里是从控制器的方法“列表”:

public JsonResult List([ModelBinder(typeof(DataTablesBinder))] 
IDataTablesRequest requestModel)
{
List<View_DFS_Akustik> myOriginalDataSet = dbman.View_DFS_Akustik.ToList();
List<View_DFS_Akustik> myFilteredData = dbman.Set<View_DFS_Akustik>().FullTextSearch(requestModel.Search.Value).ToList();

//Apply filter to your dataset based only on the columns that actually have a search value.
foreach (var column in requestModel.Columns.GetFilteredColumns())
{
    string query = column.Data + ".Contains(\"" + column.Search.Value + "\")";
    myFilteredData = myFilteredData.Where(query).ToList();
}

//Set your dataset on the same order as requested from client-side either directly on your SQL code or easily
//into any type or enumeration.
bool isSorted = false;
foreach (var column in requestModel.Columns.GetSortedColumns())
{
    if (!isSorted)
    {
        // Apply first sort.
        if (column.SortDirection == Column.OrderDirection.Ascendant)
            myFilteredData = myFilteredData.OrderBy(column.Data).ToList();
        else
            myFilteredData = myFilteredData.OrderBy(column.Data + " descending").ToList();

        isSorted = true;
    }
    else
    {
        if (column.SortDirection == Column.OrderDirection.Ascendant)
            myFilteredData = myFilteredData.OrderBy(column.Data).ToList();
        else
            myFilteredData = myFilteredData.OrderBy(column.Data + " descending").ToList();
    }
}

var paged = myFilteredData.Skip(requestModel.Start).Take(requestModel.Length);
return Json(new DataTablesResponse(requestModel.Draw, paged, myFilteredData.Count(), myOriginalDataSet.Count()), JsonRequestBehavior.AllowGet);
}


THX. Vegeta_77

uujelgoq

uujelgoq3#

I was getting the error : DataTables warning: table id=myTable - Ajax error. For more information about this error, please see http://datatables.net/tn/7  like this i checked my complete code twisly then i finally

This is my code :
var dtable;
$(document).ready(function () {
    var dtable = $('#myTable').DataTable(
        {
            "ajax": {
                "url":"~/Admin/Product/AllProducts"
            },
            "columns": [
                { "data": "name" },
                { "data": 'description' },
                { "data": "price" }                         
            ]
        });
});  for retrive data through ajax it renders data 

i changed
        "ajax": {
            "url": "../Admin/Product/AllProducts"
        }
try this code in your url : "../"

字符串

xdyibdwo

xdyibdwo4#

我的问题是在php版本。当从8. 0到7. 4版本改变时,一切都工作了。

相关问题