jQuery ajax method does not return data

Going by the jQuery docs for the call you’re using, it looks like maybe you want the success callback instead of complete. success gets passed the JSON directly, as you expect, but complete gets passed different stuff that you would have to look inside. Refer to the docs for more if you’re sure you want … Read more

Problem when sending file via ajax

Let say you have a form: <form name=”post” id=”post-form” action=”” method=”post” enctype=”multipart/form-data”> <input type=”text” name=”first_name”> <input type=”text” name=”last_name”> <input id=”file” type=”file” name=”featured_image”> </form> Now you have to pass the FormData object to ‘data’ parameter in ajax jQuery(document).ready(function($) { $(‘#post-form’).submit(function(e) { e.preventDefault(); var form = $(this); file_data = $(‘#file’).prop(‘files’)[0]; //get the file form_data = new FormData(); … Read more

Opening Modal popup on Ajax form submission

It is not right location.href = “#modal”; when you need to change hash you need to use window.location.hash=”modal” but you have another problem! You need to initialize your plugin and use its api Instead of this location.href = “#modal”; you need to use: var inst = jQuery(‘[data-remodal-id=modal]’).remodal(); inst.open()

Search function – problem with whole words

Exact means exactly that – the whole field must match, not just a word in the field. To get whole words that are part of the field, remove ‘exact’ => 1 Add this if ($_POST[‘terms’]) { $keyword = sanitize_text_field( $context[‘terms’] ); $keyword = ‘[[:<:]]’ . $keyword . ‘[[:>:]]’; $context[‘posts’] = Timber::get_posts(array( // other params here … Read more

do_action won’t work in ajax callback

Note: OP and me resolved the question/issue via chat — and despite the actual problem source is not known for sure, in the actual AJAX callback used by OP, there was actually no (or maybe OP had forgotten to make the) do_action() call. 🙂 Original Revised Answer (for reference): If you have something like so … Read more