There are three buttons:

<input type="radio" name="visible" value="1" class="checkbox_visible"/><b>View</b><br /> <input type="radio" name="visible" value="2" class="checkbox_visible"/><b>In work</b><br /> <input type="radio" name="visible" value="3" class="checkbox_visible"/><b>Done</b> 

How to make it so that when you select one of the buttons, ajax request is sent to the value selected button?

  • one
    $ ('input [type = radio] [name = visible]: selected'). val () - ilyaplot

1 answer 1

If the selector changes, you can replace it with another:

 $(document).on('click', '.checkbox_visible', function() { var value = $(this).val(); $.ajax({ url: '/path/to/file', data: {value: value}, }) .done(function() { console.log("success"); }) .fail(function() { console.log("error"); }) .always(function() { console.log("complete"); }); });