ajax 里的 url,ajax.url()

ajax.url()

Since: DataTables 1.10

Get / set the URL that DataTables uses to Ajax fetch data.

Description

While the ajax.reload() option makes it very easy to simply reload data from the existing data source, there are times when you want to change the data source URL. This method is design to fit that purpose. It can also be used to retrieve the currently set Ajax data source URL for a table.

Note that when setting a URL you will normally want to chain the ajax.url().load() method to immediately load the newly set data source URL - using ajax.url() method alone does not trigger an Ajax request, it merely sets the Ajax data source URL.

Types

function ajax.url()Returns:URL set as the Ajax data source for the table.

Note that if the Api instance refers to multiple tables, only the Ajax data source URL of the first table in the instance is returned. Use table() if you require to select a specific table from a set.

function ajax.url( url )Parameters:NameTypeOptional1urlNo

URL to set to be the Ajax data source for the table.Returns:DataTables.Api instance

Examples

Get the current Ajax data source URL:var table = $('#example').DataTable( {

ajax: 'data.json'

} );

alert( 'Data source: '+table.ajax.url() ); // Will show 'Data source: data.json'

Set the Ajax URL and load the data from the new source immediately:var table = $('#example').DataTable( {

ajax: "data.json"

} );

table.ajax.url( 'newData.json' ).load();

Related

The following options are directly related and may also be useful in your application development.

Events

Options

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值