WordPress Ajax Not Working ( Custom Admin page)

Uncaught TypeError: Cannot read property ‘ajax’ of undefined @Sasa1234, it happen cause your jQuery is undefined. Please take a look @EAMann answer. So, your JS code should like this: function myajaxfunction() { if ( undefined !== window.jQuery ) { jQuery.ajax({ //ajax request url: ajaxurl, data: { ‘action’:’rs_like_request’, ‘post_type’ : jQuery(‘#post_type’).val() // value of text box … Read more

ajax nonce verification failing

To verify nonces in Ajax requests, check_ajax_referrer() should be used instead of wp_verify_nonce(): Crete the nonce: $nonce = wp_create_nonce( ‘vote-nonce-‘ . get_the_ID() ); Include it in JavaScript: jQuery(document).ready(function(){ jQuery(“.post-voting”).click(function(){ vote_nonce = <?php echo $nonce; ?> vote_id = jQuery(this).data(‘vote-id’); jQuery.post( vote_ajax.url, { action: ‘submit_vote’, vote_id: vote_id, vote_nonce: vote_nonce }, function( data ) { alert( jQuery.parseJSON(data) ); … Read more

problem with WordPress ajax

In general, when a ajax call usgin admin-ajax.php returns zero it means that the action is not set in the request data, or that the action callback is not found. In your case, it seems that the action callback is not found. When performing ajax call in the frontend, you need to use the action … Read more

register ajax calls hook

Any action that fires before the AJAX call is made will work. Generally speaking, init is good choice. You mention that the ajax call is made from a “front-end form”. If that form is available to end-users who are not logged in, then you need to use: add_action (‘wp_ajax_nopriv_my_plugin_etc’, ‘my_plugin_etc’) ; See wp_ajax_nopriv_{$_REQUEST[‘action’]}. Edit Must … Read more

My ajax code not returning ajax value

In above case your ajax request is not reaching your php function, thus it founds nothing. Update your jquery function with this function jqueryfunction(id) { var value = jQuery(this).val(); if (value.length > 3) { jQuery.ajax({ url: ajaxurl, type: ‘POST’, data: { action: ‘mycustomfunction’, value: value, }, success: function (data) { console.log(data); } }); } else … Read more

Get wp_title wp ajax

YOAST’s SEO Title is stored within a meta_key. Try this- $taxonomy = get_queried_object()->taxonomy; $term_id = get_queried_object()->term_id; $meta = get_option( ‘wpseo_taxonomy_meta’ ); $title = $meta[$taxonomy][$term_id][‘wpseo_title’]; Or this- $titles = get_option( ‘wpseo_titles’ );

wp_create_nonce() in REST API makes user->ID zero

I know it pasts a long time of this question. But I had the same issue and it was difficult for me to find some documentation about it. I had the same problem, for some reason wp_create_nonce and wp_verify_nonce they bot retrieve different hash. So I notice the problem was the $User->ID or $uid that … Read more

Updating a checkbox value to database for specific row in table

Rough answer to get you started. Inside the loop, use the row’s record number (a field called ‘IDnumber’, unique, auto) to help name the of a . The hidden <input> should have an id of something like <input hidden name=”idnumber” value=”<?php echo $row[idnumber];?>”> which will cause the vaue of that input field to be the … Read more

Getting back to ajax search results from a page

I solved this using the HistoryAPI. Since my ajax returns objects that has response, html and query, I pushed the html results of the search to the history state with window.history.pushState( date_out.html, null, null); where data_out is the object returned from the ajax call. Then I added a button on the single advert page that … Read more