Cheat Sheet

Sample AJAX Call in WordPress


$jx.ajax({
url: ajaxurl,
dataType: "json",
type: 'POST',
data: 'action=get-style-css&editor-id=' + $editor_id + '&builder-id=' + $builder_id + '&styles-tab-selector=' + $styles_tab_selector,
success: function(result) {
//actions here
}
});

add_action('wp_ajax_init_ts_data', array($this, 'ajaxInitTSData'));
add_action('wp_ajax_nopriv_init_ts_data', array($this, 'ajaxInitTSData'));

public function ajaxInitTSData() {
$ret['success'] = true;
print_r( json_encode($ret));
exit;
}