I need to pass the path to a php file (located in a folder in my theme) to a JS file being used in my admin area but I have no idea how to accomplish that.
What Im trying to do, is build a page where selecting some options in a form will pass the input's value to a php script via ajax. But because JS is client side, I dont know how to point to the correct location.
I tried testing using this:
<?php wp_enqueue_script( 'some_handle' ); $translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_value' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array ); wp_enqueue_script("admin", $adminDir."js/admin.js", false, "1.0"); ?>
with this in my admin.js:
But console just reads:
ReferenceError: object_name is not defined