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
Add the "exit" end of the function as shown below, this will fix the return 0 with the response in WordPress on using the ajax request.
add_action('wp_ajax_nopriv_getStateList', 'getStateList');
add_action('wp_ajax_getStateList', 'getStateList');
function getStateList() {
global $wpdb;
$countryId = $_POST['countryId'];
$results = $wpdb->get_results("SELECT id,name FROM regions where country_id ='".$countryId."' ");
echo json_encode(array('status'=>200,'data'=>$results));
exit;
}