/** * Send an action via admin-ajax.php * * @param {string} action - the action to send * @param * data - data to send * @param Callback [callback] - will be called with the results * @param {boolean} [json_parse=true] - JSON parse the results */ var klick_apv_ui_send_command = function (action, data, callback, json_parse) { json_parse = ('undefined' === typeof json_parse) ? true : json_parse; var ajax_data = { action: 'klick_apv_ajax', subaction: action, nonce: klick_apv.klick_apv_ajax_nonce, data: data }; jQuery.post(klick_apv.ajaxurl, ajax_data, function (response) { if (json_parse) { try { var resp = JSON.parse(response); } catch (e) { console.log(e); console.log(response); return; } } else { var resp = response; } if ('undefined' !== typeof callback) callback(resp); }); } /** * When DOM ready * */ jQuery(document).ready(function ($) { klick_apv_ui = klick_apv_ui(klick_apv_ui_send_command); }); /** * Function for sending communications * * @callable sendcommandCallable * @param {string} action - the action to send * @param * data - data to send * @param Callback [callback] - will be called with the results * @param {boolean} [json_parse=true] - JSON parse the results */ /** * Main klick_apv * * @param {sendcommandCallable} klick_apv_ui_send_command */ var klick_apv_ui = function (klick_apv_ui_send_command) { var $ = jQuery; // Define plugin ui script }