jQuery(document).ready(function($) { $('body').on('click','#akbar_button_ajax',(event)=>{ event.preventDefault(); var akbar_button_ajax=$('#akbar_button_ajax'); if(akbar_button_ajax){ akbar_button_ajax.text('...'); } var data = { 'action': 'akbar_ajax_action', 'akbar_we_value': ajax_object.akbar_we_value // We pass php values differently! }; // We can also pass the url value separately from ajaxurl for front end AJAX implementations jQuery.post(ajax_object.ajax_url, data, function(response) { alert('Got this from the server: ' + response); if(akbar_button_ajax){ akbar_button_ajax.text('Create'); } }); }); });