How to Object.freeze wp_localize_script
No, it is not possible to do this from wp_localize_script(). You would need to add add Object.freeze( text_ajax ); to the beginning of your script.
No, it is not possible to do this from wp_localize_script(). You would need to add add Object.freeze( text_ajax ); to the beginning of your script.
Ajax login fails: script sets cookies, but is_user_logged_in() returns false
Dynamic Twitter card images
You have use ajaxurl when make post request – it’s right way but it also mean that now $wp_query, in your my__load__more() function, work with your.site/wp-ajax url instead of your.site/taxonomy. That’s why you couldn’t get category name from $wp_query->query_vars. First, I use add_action( ‘wp_enqueue_scripts’, ‘my__enqueue’ ); for enqueue your scripts (see example below). Second, I … Read more
Is there a hook that fires after an ajax call?
Just another suggestion you could try. Rather than doing a separate AJAX call, could you just send it to your script via wp_localize_script? I’m not sure if that would have any effect on your particular bug, but it’s worth a shot? // Make data accessible to scripts wp_localize_script( ‘my-script-handle’, ‘ajax_data’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ … Read more
There are 2 problems: Problem 1 Your AJAX endpoint looks for my_id: $id = $_POST[‘my_id’]; But your javascript sends id: id : my_id Importantly: id != my_id They do not match. There is no $_POST[‘my_id’], that’s why you get a PHP notice Problem 2 You’re using $_POST but the code does not make a POST … Read more
Admin Ajax always return 0
After deep meditation and a meeting with dally the llama (maybe it was an alpaca, I was quite high), I’ve defined a solution. Use the widget-updated var to reload the JS function on widget save. $(document).on(‘widget-updated’, function(event, widget) { doAccordion(); });
how to make sure js is enabled before executing php function