S
S
Sergey Valitov2016-02-12 18:06:01
JavaScript
Sergey Valitov, 2016-02-12 18:06:01

How to execute js in wordpress plugin?

Hello! Guys, such a question. I have a plugin, and on action Init I hang up a function that first takes data from the database ($wpdb->get_results), and then translates it into json for a js script. But js is apparently forbidden in the body of the plugin, and I need to somehow pass json to the js script .. if done through wp_enqueue_script(), then json cannot be passed .. Can someone tell me something?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Ninja Mate, 2016-02-12
@victorzadorozhnyy

jQuery and Ajax will help you
wordpress.stackexchange.com/questions/168692/cant-...

I
Igor Vorotnev, 2016-02-14
@HeadOnFire

Have you looked at wp_localize_script() ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question