Plugin Admin Page Ajax-Admin call returning 0, URL set correctly. Implemented localized scripts but did not fix it

Hi please try below code jquery : $(‘#saveMediaButton’).click(function(e) { e.preventDefault(); $.ajax({ url : my_ajax_object.ajax_url, type : ‘post’, data : { action : ‘action_upload_img’, image_attachment_id : document.getElementById(“image-preview”).getAttribute(‘src’) }, dataType : ‘html’, success : function( response ) { var jsonData = response; console.log(response); console.log(document.getElementById(“image-preview”).getAttribute(‘src’)); }, error : function(jqxhr, textStatus, errorThrown) { console.log(my_ajax_object.ajax_url); console.log(jqxhr); console.log(textStatus); console.log(errorThrown); }, }); … Read more

Help me with my first very basic plugin

I have already answered this question stackoverflow, but adding the answer here as well: Looking on the code it does not seem like the WordPress way of doing this kind of thing. First you need to include your ajax-process.php in the plugins main file e.g: require_once plugin_dir_path(__FILE__) . ‘/ajax-process.php’; Second, you need to register your … Read more

WordPress Pagination with ajax – Dots

You can use “mid_size” to manage number of pages to display in paginate_links() function. Please check https://developer.wordpress.org/reference/functions/paginate_links/ for pagination options. Please see example below to use mid_size. $args = array( ‘mid_size’ => 3, ‘prev_next’ => true, ‘prev_text’ => ‘« Previous’, ‘next_text’ => ‘Next »’, ); $result = paginate_links($args);

WordPress sound bell when new data will add

There may be browser restrictions preventing autoplaying audio, see this answer https://stackoverflow.com/questions/53058421/local-variable-audio-in-object-method-not-playing You can see this in your browser developer tools console, there will be error like this NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. If this sound … Read more

Response from Php File to Ajax is not getting sent

Issue Solved I was missing a closing brace for data… jQuery(document).ready(function($){ $(“#login_otp_btn”).click(function(event){ val(); event.preventDefault(); jQuery.ajax({ url: wpac_ajax_url.ajax_url, type:’POST’, data :{ dataType:’JSON’, action : ‘login_ajax_callback’, login : $(“#login_mobile”).val(), } success:function(response){ console.log(“url wpac ” + wpac_ajax_url.ajax_url); if(response !== “”){ response = JSON.parse( response ); console.log(response); }else{ console.log(“Response is empty”); } }, }); $(“#login_otp_field”).show(); }) });