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

Sending variable from ajax on form submit

in your html form add <input name=”action” type=”hidden” value=”test_function”/> . here “value” is your “action_name”. Your ajax call is incorect. Data should be url: “your php action script” data: $(‘form#filter).serialize(), About ajax first try to create ajax on your computer without wordpress. When you understand how ajax work try on WordPress. if you want to … Read more