React to AJAX adding to the page

Found this at https://codex.wordpress.org/AJAX_in_Plugins JavaScript triggering the post-load event after content has been inserted via Ajax: jQuery( document.body ).trigger( ‘post-load’ ); JavaScript listening to the post-load event: jQuery( document.body ).on( ‘post-load’, function () { // New content has been added to the page. } ); I suppose it’s up to each plugin to trigger whichever … Read more

jQuery AJAX url wit variable

try with Axios instead jQuery and check the response, example let form_data = new FormData; form_data.append(‘action’, ‘myAction’); form_data.append(‘first_name’, ‘my first name’); axios.post(myVars.ajax_url, form_data).then(function(response){ console.log(‘response’, response.data); }).cath(console.log)

Ajax not sending the data correctly- Multidimensional array

Anwer is yes it does limit. This server parameter max_input_var sets it. You may have to increase it make it work. php documentation : max_input_var : How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). Use of this directive mitigates the possibility of denial of service attacks … Read more

404 error custom post type rest api

You need to declare that your CPT supports REST via show_in_rest when registering it, then use the REST API endpoint for that post type. For example, I have a CPT on my own site for talks named tomjn_talks, and it has an endpoint at /wp/v2/tomjn_talks

400 Bad Request getting on AJAX Call

Your have to use full url of ajax function. I have use ajax_url in your Ajax Call – footer.php(theme footer) file code. <script> var ajax_url = “<?php echo admin_url( ‘admin-ajax.php’ ); ?>”; jQuery(function() { jQuery(“#calc_form”).on(“submit”, function(e) { // alert(“submit”); e.preventDefault(); jQuery.ajax({ method: “POST”, url: ajax_url, data: { action: ‘calculation’, message_id: jQuery(‘#tot_tax_three_month_Input’).val() }, dataType: ‘json’, success: … Read more

JS global variable doesn’t update

If you want to create global variable intentionally you need to do this. window[‘your_variable_name’]= ‘Some variable value’; then you’ll be able to access it like window.your_variable_name – this way of creating and accessing global variable guarantees that you will work with same variable regardless of what build tools like webpack or from where you access … Read more

Ajax is not defined

jQuery is not defined because you’ve not referred jQuery as dependency for your script so wp isn’t aware it should load it for your script. wp_localize_script should be called on script that is already linked via wp_enqueue_script, so you first run wp_enqueue_script then wp_localize_script as you do in your UPD. Another thing about wp_localize_script is … Read more