How to declare a JS variable in an AJAX call
The right way is to post the data back to the WordPress admin ajax url then in your PHP function access them using the $_POST variables. Example jQuery function that passed a category id back to wordpress: function cat_edit_get() { jQuery( “#loading-animation”).show(); var catID = jQuery(“#cat :selected”).val(); var text = jQuery(“#cat :selected”).text(); jQuery(‘#replace’).html(text); jQuery.ajax({ type: … Read more