Customizer AJAX using buttons

Having any AJAX inside of the customizer defeats the reason for using the customizer in the first place. The idea of the customizer is that it fully controls the state of the settings while it is active, and having any setting being updated without going via the customizer logic can actually cause a mismatch between … Read more

Ajax comment form submit on frontpage alerts success but no insertion

It took a while, but this works (a comment is created, albeit with still some missing values, but fixing that part is easy) Biggest changes: For some reason an ‘echo’ in functions.php was important. Also, I changed the ‘action’ in ajaxtry2.js under data: HTML (values are fictional) <form id=”commentform” class=”commentform”> <label for=”comment”></label> <textarea id=”comment” class=”comment” … Read more

How get child posts in custom post type by ajax?

To retrieve the post details you have to send the data yourself. In your JavaScript code you did not send post id. Update your code like this: data:{ action: “applications_filter”, post_id: current_post_id, //current_post_id should either parsed from DOM or you can write your ajax in PHP file } You must need to send post_id before … Read more

Making an ajax request from a different domain

If you want to use Admin-Ajax to output the content, you should use echo instead. There is nothing to be viewed when you use return, so you’ll get a 0. This quotation from the codex explains further about the 0 response: If the Ajax request fails in wp-admin/admin-ajax.php, the response will be -1 or 0, … Read more

Admin-Ajax Error

You need to pass the values to the localization script, “right” after this line: wp_enqueue_script(‘rnm_load_more’); I’m going to pass the admin URL to your script by using wp_localize_script: $localization = array( ‘ajax_url’ => admin_url(‘admin-ajax.php’), ); wp_localize_script( ‘rnm_load_more’, ‘jjang’, $localization ); Now, you can use the ajax_url in your script: var ajaxurl = rnm_load_more.ajax_url; You can … Read more

How to load content from many posts on a page, only if needed

You could use LazyLoading too, just put the URL for the image in a data-src attribute in the element <img/>, then on click your anchor, copy the data there to the src attribute. Maybe your lightbox plugin offers an event or config option to put your handler, using jQuery I’d use something like this: $(‘a.load-lightbox’).click(function(e) … Read more