最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What exactly is the sAjaxSource parameter in datatables? - Stack Overflow

programmeradmin3浏览0评论

According to datatables website,

sAjaxSource
You can instruct DataTables to load data from an external source using this parameter (use aData if you want to pass data in you already have). Simply provide a url a JSON object can be obtained from. This object must include the parameter 'aaData' which is the data source for the table.

Now, to me (an amateur with Ajax and JSON), this is gibberish.

I want my datatable to paginate, and load new entries using Ajax each time the table is re-sorted or the next page is chosen (instead of loading all entries up front)

Apparently this "url a JSON object can be obtained from" is needed if I want to set the bServerSide option to true

Is there anyone that can explain this concept to me?

According to datatables website,

sAjaxSource
You can instruct DataTables to load data from an external source using this parameter (use aData if you want to pass data in you already have). Simply provide a url a JSON object can be obtained from. This object must include the parameter 'aaData' which is the data source for the table.

Now, to me (an amateur with Ajax and JSON), this is gibberish.

I want my datatable to paginate, and load new entries using Ajax each time the table is re-sorted or the next page is chosen (instead of loading all entries up front)

Apparently this "url a JSON object can be obtained from" is needed if I want to set the bServerSide option to true

Is there anyone that can explain this concept to me?

Share Improve this question edited Mar 6, 2014 at 11:20 mainguy 8,3312 gold badges34 silver badges40 bronze badges asked Mar 5, 2014 at 10:26 Marco PrinsMarco Prins 7,41913 gold badges48 silver badges79 bronze badges 2
  • Look at my lengthy Answer here: stackoverflow./questions/21704398/… – mainguy Commented Mar 6, 2014 at 10:50
  • And maybe this one: stackoverflow./questions/22156229/… – mainguy Commented Mar 6, 2014 at 10:52
Add a ment  | 

2 Answers 2

Reset to default 2

In server-side processing you can choose either of two ways:

  1. Serve JSON from the same URL, which you use to show HTML page with a table (page with table is on www.example./table and AJAX call to www.example./?sEcho=1&andOtherParametersHere) - you do not need specify sAjaxSource, because datatable's script joins the parameters to the existing URL.

  2. Serve JSON from URL that is different from one you use to show HTML page with table (so page with table is on www.example./table and AJAX call to www.another./?sEcho=1&andOtherParametersHere) - you must specify sAjaxSource to www.another..

Simply put, it's the URL that returns your DataTables content that you want to display (your data source for server-side processing).

If you need more details, there are plenty of links in the other replies that detail it.

发布评论

评论列表(0)

  1. 暂无评论