question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using the cookie plugin, the first ajax call isn't fired

See original GitHub issue

When using the cookie extension it looks like the overridden _initServer in the extension returns too early and never tries to call the url here https://github.com/wenzhixin/bootstrap-table/blob/develop/src/extensions/cookie/bootstrap-table-cookie.js#L302-L305 I’m not sure what the logic is doing here, hence no patch 😃

Example: https://jsfiddle.net/spfgx18g/1/

When you load this you see the url is never called. If you comment out the cooke and re-run it will call the URL.

This also presents itself with serverside pagination, the first call is not sent but sorting will then send the ajax call.

May be related to https://github.com/wenzhixin/bootstrap-table/issues/2483 as well

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pandomiccommented, Jan 6, 2017

It seems that it is js’s typecast issue. In Cookie.js we have:

cookiesPresent = function() {
    return bootstrapTable.options.cookie && bootstrapTable.getCookies(bootstrapTable);
};
// ...
if (cookiesPresent() && selectsWithoutDefaults.length === 0) {
    return;
}

If you try in console false && [] you will get expected false, but unfortunately if you try true && [] you’ll got Array instead of Boolean, that;s why return; will be executed even if cookies are not presented.

So solution is pretty simple, we need just to change

return bootstrapTable.options.cookie && bootstrapTable.getCookies(bootstrapTable);

to

return bootstrapTable.options.cookie && bootstrapTable.getCookies(bootstrapTable).length;
1reaction
vingoriuscommented, Sep 6, 2016

@wenzhixin , Could you update this module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is jQuery's .ajax() method not sending my session cookie?
I am operating in cross-domain scenario. During login remote server is returning Set-Cookie header along with Access-Control-Allow-Credentials set to true.
Read more >
jQuery API Documentation
jQuery API. jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, ...
Read more >
Getting started - Developer guides - MDN Web Docs
This article guides you through the AJAX basics and gives you some simple hands-on examples to get you started.
Read more >
PHP setcookie() Function - W3Schools
A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with...
Read more >
PHP cookie not set within AJAX call
Apparently I was missing the time() attribute. So when adding this to the expire option in the setCookie function, the cookie is being...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found