I\'ve setup the basic wordpress ajax example in my wp theme. The trigger is made by modernizr.js checking the media queries on the page.
jQuery(document).rea
Everything has to match here:
PHP
add_action('wp_ajax_my_action', 'my_action');
add_action('wp_ajax_nopriv_my_action', 'my_action');
function my_action() {}
JS
var data = {
action: 'my_action',
whatever: ajax_object.we_value
};
Also, you're missing security checks and a better handling of the response.
Check this examples: [ 1 ] and [ 2 ].