Skip to navigation
Jquery ajax toggle button example
16.06.17
// c_yes and n_no is css class for the button // jQuery.global.data.base_url is the url from the body data tag jQuery('#customer_form button').on('click', function(e) { var data = {}; var element = this; data[this.name] = jQuery(this).val(); jQuery.ajax({ url:jQuery.global.data.base_url +'general/customers/index_exe', type:'POST', data:data, success:function(r) { jQuery(element).removeClass('c_no'); jQuery(element).val(r['value']); if(r['val'] == 'yes') { jQuery(element).removeClass('c_no'); jQuery(element).addClass('c_yes'); element.innerHTML = 'yes'; } else { jQuery(element).removeClass('c_yes'); jQuery(element).addClass('c_no'); element.innerHTML = 'no'; } } }); });
https://api.jquery.com/jQuery.ajax/
Reply
Anonymous
Information Epoch 1732656643
Use software leverage to your advantage.
Home
Notebook
Contact us