Set the timeout (timeout) method when BootstrapTable requests data. connecttimeout times out.

Source: Internet
Author: User

Set the timeout (timeout) method when BootstrapTable requests data. connecttimeout times out.

When you use bootstrapTable to obtain data, sometimes the data cannot be obtained in time due to network or server reasons, and the page is always waiting. To improve the effect, consider setting the timeout. After the request is sent, no data is displayed, and the request is re-initiated after a period of time.

In implementation, bootstrapTable obtains data through ajax. You can use the ajaxOptions option to set some attributes of ajax.

To set timeout for bootstrapTable, set the async attribute to true. In bootstrapTable, the default value of async is false. For example

$("#event_table").bootstrapTable({ url: urlAddr, ajaxOptions: {async:true,timeout:5000},});

In addition, adding ajaxOptions using the refresh method does not work:

$(“#event_table”).bootstrapTable('refresh', {  url: api_url,  ajaxOptions:{async:true,timeout:1000}});

The reason remains to be further investigated.

Next, let's take a look at how to know if table data is successfully loaded when bootstrapTable is used to obtain data?

BootstrapTable provides a special loadsuccess method to reflect whether data is successfully loaded.

$table.on('load-success.bs.table',function(data){  console.log("load success"); });

BootstrapTable user documentation, see http://bootstrap-table.wenzhixin.net.cn/documentation/

Refer:

Difference between refresh and refreshOptions of boostrapTable

The above section describes how to set a timeout value for BootstrapTable data request. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.