Remove value from array within post meta ajax admin

You’re not printing anything from the AJAX callback. Trying using wp_send_json_success: function ajaxtestdel(){ global $post; $currentPdfs = get_post_meta( $post->ID, ‘pdf_upload_url’, true ); $postValue = isset($_POST[‘postid’]) ? $_POST[‘postid’] : ”; $array_without_strawberries = array_diff($currentPdfs, array($postValue)); update_post_meta( $post->ID, ‘pdf_upload_url’, $array_without_strawberries ); // Send something back to AJAX wp_send_json_success(); } I have a feeling that perhaps your jQuery selector … Read more

fill form fields with ajax response

First, I can count on one finger the number of times A code which was developed in the hope of being “reusable” was actually reused. Write the code to the specification you can test against. “Reusable” is not a specification you can test against until you have a proper idea what will you need in … Read more

Use Contact Form 7 with Ajax

It is hard to give a 100% answer without seeing the code of how the shortcode is being registered, but from your description it sounds like it is not being registered when ajax requests are being processed. The reason is probably because ajax requests are being handled in an “admin” conttext, and shortcodes are a … Read more

How to get post from pure frontend AJAX (using only post ID)?

You can output your javascript via wp_add_inline_script(). This way you can set the post”s id and AJAX URL before outputting the code: wp_add_inline_script(‘my-js’, ‘ jQuery.ajax({ \’url\’ : ‘.admin_url(‘admin-ajax.php?action=my_action’).’ data : { \’id\’ : ‘.get_the_ID().’ } });’); Note that you need to hook to an existing js file to be able to add inline script, so … Read more

why does not work ajax that add_action registered in wordpress

The AJAX request is a separate request from the one that renders your page. Your AJAX handler is getting registered on the request that serves the page, but not the AJAX request, which is the one that matters. Move your add_action and function to your theme’s functions.php file, which loads on all requests.

How To Render Shortcode In AJAX Response?

In general, sshortcodes are not a programming construct, they are content macros. As content macros, their viability in being used outside of their content context is limited. Simplistic shortcodes, like the gallery/audio/video (and I am not sure even about them) might “render” without context, but advanced ones will need a properly set loop, and calls … Read more

Front end theme options ajax returns 0

You’re sending a bad action for your AJAX request, the action should match with your string next to wp_ajax_: add_action(‘wp_ajax_fend_theme_data_save’, ‘fend_theme_data_save’);, so your action HTML field should be like this: <input type=”hidden” name=”action” value=”fend_theme_data_save” /> See the difference? Your action value should always be next to wp_ajax_ or wp_ajax_nopriv, whatever you’re using. I recommend you … Read more