Using AJAX for dynamic settings pages
I found a solution without ajax. I just put all the data to a json-file and used a jquery-client-solution as described here: http://css-tricks.com/dynamic-dropdowns/ .
I found a solution without ajax. I just put all the data to a json-file and used a jquery-client-solution as described here: http://css-tricks.com/dynamic-dropdowns/ .
To Ajaxify the request you need two parts, a php function, hooked to the wp_admin_ajax ( and the wp_admin_ajax_nopriv if you want it to be available for non logged in user) and a JavaScript to request the AJAX. PHP add_action(‘wp_ajax_getpost_by_year’,’process_getpost_by_year’); add_action(‘wp_ajax_nopriv_getpost_by_year’,’process_getpost_by_year’); function process_getpost_by_year(){ $year = $_REQUEST[‘year’]; $args = array( ‘post_type’ => ‘post’, ‘ignore_sticky_posts’ => 1, … Read more
get_comments() returns empty array if called through AJAX
Wrapping it in a function and then adding the following did the trick: add_action( ‘wp_footer’, ‘my_ajax_script’ ); // Write our JS below here Was all it took
Ajax Form data is not posted back to the get_results()
Yep, this is nasty issue that to have full WordPress environment you need to spend considerable time loading it. I’ve needed much better performance (for very dynamic incremental search feature) for work and what I went with is: Custom file as Ajax handler. SHORTINIT constant for limited WP core load. Very selectively loaded parts of … Read more
WordPress page content only in fancybox except direct click
wp_enqueue_media problem
The jQuery .html and .load() is replacing the entire content. First, move your #Pagination outside of the ul.list-group. You will want this to continue to remain at the bottom of the list. Next, you will need to reconfigure your jQuery ajax to load the posts differently. You should load the posts from the next page, … Read more
Untested but … You need to pass your “action” identifier with the data, like so: var data = { ‘action’: ‘my_action’, ‘whatever’: 1234 }; In your case, that action would be get_number_of_promos. The example is from the Codex page about AJAX, which you should read carefully: https://codex.wordpress.org/AJAX_in_Plugins