ajax response -1 in wordpress theme

Pay attention that your ajax request will work only for logged in users. If you want to make it working for everybody, you have to add one more action wp_ajax_nopriv_myajaxpagination with the same hook: function videospage(cnt) { var pageno=cnt; jQuery.ajax({ type: “POST”, url: “<?php echo admin_url(‘admin-ajax.php’); ?>”, data: { action: “myajaxpagination”, pageno: pageno, }, success: … Read more

update_option is not saving an array, but saving the string ‘Array’

It sounds like your array isn’t being serialized before updating the option for whatever reason. Perhaps due to ajax or just your particular situation. Try this: // … $option[ ‘apps’ ][] = $new_app; if( ! is_serialized( $option ) ) $option = maybe_serialize( $option ); $data = update_option( ‘vm_fbconnect’, $option ); // …

Use Ajax To filter posts?

I’d go with @Vinicius’ answer with the following changes: Change type: ‘GET’ to type: ‘POST’ Change ajax: 1 to action: ‘filter_posts’ Replace add_action(‘init’, ‘check_ajax’); with: add_action(‘wp_ajax_filter_posts’, ‘check_ajax’); add_action(‘wp_ajax_nopriv_filter_posts’, ‘check_ajax’); Remove: if (!isset($_POST[‘ajax’])) return false;

Creating an auto result search bar

Then “autoSearch.php” has this code: If that’s all there is, no wonder you get an error – WP isn’t even loaded! Add this to your functions.php isset( $_POST[‘autoSearch’] ) && add_action( ‘after_setup_theme’, ‘wpse_60353_autosearch’ ); function wpse_60353_autosearch() { // The autoSearch.php code you posted in your question exit; // All done, stop WP continuing } Now … Read more

How to keep track of when a vote is cast?

The following lines of code both store the IP address and time of vote, // $ip holds $_SERVER[‘REMOTE_ADDR’] $voted_IP[$ip] = time(); // Save IP and increase votes count update_post_meta($post_id, “voted_IP”, $voted_IP); The time a vote is cast is already being stored for you in the post_meta table for the given post the person is voting … Read more

where do I send my ajax calls

If you need to use the WordPress enviorment and functions in your ajax processing funciton then you need to post/get your AJAX request to admin-ajax.php, So change ‘ajaxurl’ => plugin_dir_url(‘my_plugin.php’) to ‘ajaxurl’ => admin_url(‘admin-ajax.php’)

Sorting WP Auctions by date/price?

<a href=”https://wordpress.stackexchange.com/questions/77197/<?php bloginfo(“template_url’); ?>/auction_price.php”>Order by price</a> auction-price.php is inside the template directory. Then you can’t include wp-blog-header.php using require(‘./wp-blog-header.php’) inside template directory. Therefore do_shortcode() is not working without WordPress. The proper way to use ajax in WordPress is via admin-ajax.php Read More at Codex: http://codex.wordpress.org/AJAX_in_Plugins For example, in your functions.php: function wpse_77197_auction_price(){ echo do_shortcode(‘[wpa_list_widget mode=”list” … Read more

Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin

Have a read of AJAX in Plugins, then see if you can adapt this code to what Highcharts is wanting: add_action(‘wp_ajax_wpse_77392_get_json’, ‘wpse_77392_get_json’); add_action(‘wp_ajax_nopriv_wpse_77392_get_json’, ‘wpse_77392_get_json’); function wpse_77392_get_json() { global $wpdb; $sql = ” SELECT `date`,`value` FROM {$wpdb->prefix}table_name WHERE `date` BETWEEN ‘2011’ AND ‘2012’ ORDER BY `date` ASC; “; $results = $wpdb->get_results($sql); $json = json_encode($results); header(‘Content-type: application/json’); … Read more