How to enqueue or include json file to a plugin
-
Hi,
I have a file called settings.html that include two files in the footer which are a javascript file and a json file.
<script src="script.js"></script> <script src="settings.json"></script>
Basically, my javascript file needs the json file to work properly.
In my plugin.php file I enqueued my javascript file as well as my json file like this.
I know how to enqueue a javascript but not a json file so I tried something like that.function register() { wp_enqueue_script( 'json_settings', plugins_url('settings.json', __FILE__,true) ); wp_enqueue_script( 'js_script', plugins_url('script.js',array(json_settings) ,__FILE__),true ); } add_action( 'admin_enqueue_scripts', 'register' );
The problem here is that my javascript file works but without the json file. My javascript file cannot reach the datas inside the json file.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to enqueue or include json file to a plugin’ is closed to new replies.