lundi 9 novembre 2015

control checkbox action with ajax

I am using CSS toggle button to show active or inactive. It uses a HTML checkbox and modifies its CSS to look like toggle slide bar. I have bound the onClick event on the checkbox so that when the checkbox is checked it sends id via an AJAX request to a URL that updates the status of the row with the given id to active and echoes active. The PHP echo returned by URL is now displayed below the toggle button.

Here, when checkbox is clicked first the checkbox is checked and the AJAX request is sent to the URL, what I want is when the checkbox is clicked the checkbox doesn't get checked or unchecked but the AJAX request is sent and when response arrives then only change status of checkbox to checked or unchecked as per the response. How can I achieve this? Can someone clarify with an example?




Aucun commentaire:

Enregistrer un commentaire