Ajax Plugin Not Echoing Response

This is the final code I am using. Thanks to webaware for pointing out that I was not using the correct datatype. jQuery(document).ready(function($) { $(‘.audience_intel_container .close’).click(function(){ $(‘.audience_intel_container’).fadeOut(‘fast’, function(){ }); }); $(‘.audience_intel_container button’).click(function(){ console.log(‘clicked’); var formdata = $(‘#audience_intel_form’).serialize(); $.ajax({ type : “post”, dataType : “html”, url : audience_intel_js.ajaxurl, data : ‘action=audience_intel&’+formdata, success: function(response) { alert(response); $(‘.audience_intel_container’).html(response); … Read more

Ajax for subscibers not working

If an AJAX function does not work properly, in most cases you forgot to allow Users with no or little privileges to access the function. Adding the Callback Function is quite simple: add_action(‘wp_ajax_my_action’, ‘my_action_callback’); Now you need to do the same thing for the “not-so-privileged” users: add_action(‘wp_ajax_nopriv_my_action’, ‘my_action_callback’); With these two lines everything should work … Read more

wordpress widget missing jquery

Your first two problems: $ and jQuery is not defined. $ is just an alias for jQuery. Your first two problems are the same with different names. I think you do not write a plugin or a function in your functions.php. I think you put your code simply in the template file and expect that … Read more

Ajax Validation for reCaptcha

Just found out that reCaptcha actually rejects CAPTCHAs which are submitted to their server more than once. Since I was using the WP-reCAPTCHA plugin, the plugin resubmitted the CAPTCHA after my AJAX submission. So I just commented out a line from the plugin that does the submission, which is in file recaptcha.php, line 27: $this->register_filters();

Plugin AJAX Save to Custom Table

Please use the available API – as you have it in your question I could take down your entire site in a second. (I wrote this tutorial on Data Sanitization and Validation – the last section is particular relevant to you). As for it not inserting the data, you should check WP_DEBUG is turned on, … Read more

custom autocomplete search

I found my problem. It was just a problem from my search php script! Without trim( $_REQUEST[‘term’] ) it will not correctly filter results. Now like this it works perfectly: function search_autocomplete(){ $posts = get_posts( array( ‘s’ => trim( $_REQUEST[‘term’] ), ‘post_type’ => array(‘post’, ‘portfolio’) ) ); $suggestions=array(); global $post; $args = array(‘post_type’ => array(‘post’, … Read more

Create WordPress posts from JSON array using plugin in admin

Here I assume your json is an array of object where properties are named like wp_insert_post arguments: ‘post_title’, ‘post_content’ and so on. function process_ajax() { if ( ! isset($_POST[‘nonce’]) || ! wp_verify_nonce($_POST[‘nonce’], ‘mynonce’) ) die(‘error on checking nonce’); if ( ! isset($_POST[‘filepath’]) die(‘no file given’); if ( ! file_exists($_POST[‘filepath’]) ) die(‘invalid file given’); $posts = … Read more

Serve a different theme based on window size

You shouldn’t need to use a different theme. A good responsive theme should handle all sorts of device window sizes. The new default WP theme, Twenty Thirteen, is responsive mobile first and changes for different device screen sizes. http://wordpress.org/themes/twentythirteen