Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send via Ajax at the click? #154

Open
OursEnSki opened this issue Mar 13, 2018 · 1 comment
Open

Send via Ajax at the click? #154

OursEnSki opened this issue Mar 13, 2018 · 1 comment

Comments

@OursEnSki
Copy link

Hello

I'm looking for just sent ajax at the time of "Change", it works, but it sends twice the data ...

If I do :
$ ( '# SuivreGeo'). Change (function () { ... $ .ajax ({ method: 'POST', ...
It seems to me that at the moment of "change" it launches two actions giving the current state, then the state changed.

If I put "click" instead of "change" it sends once the information, but in this case the switch status no longer changes :(

How to send directly to Ajax when clicking on the Switch?

Thanks for your help.
Have a good day

@tsuijie
Copy link

tsuijie commented May 23, 2018

Try this:

$ ( '# SuivreGeo'). Change (function () {
    if ($(this).attr('disabled) == 'disabled') return false;
    $(this).attr('disabled', 'disabled');
    $.ajax({
      ...
    }).complete(function () {
      $(this).removeAttr('disabled')
    })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants