Ad
Jquery How To Use Find() To Find The Variable Inside The Script Tag?
I have the webpage with a <script> var nUos={//json} </script>
how can i get that variable using find? Not sure if i can use that.
// if you are a Wordpress user I have a variable that is dynamic being passed to the WordPress pages using localize script functionality Please help
Ad
Answer
Assuming you are using wp_localize_script
(something) like:
wp_localize_script('my-script', 'nUos', array('foo' => 'bar'));
nUos
will be made available to you by means of the window
object:
console.log(window.nUos)
//-> {foo: "bar"}
Sidenote: nUos
is not JSON, it is a JS object literal.
Ad
source: stackoverflow.com
Related Questions
- → OctoberCMS - How to make collapsible list default to active only on non-mobile
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → when i send data with ajax(jquery) i don't find the values in controller without form in laravel 5.1
- → DropzoneJS & Laravel - Output form validation errors
- → Knockout JS - How to return empty strings for observable fields
- → How to replace *( in a string
- → Get the calling element with vue.js
- → Sent Variable to Controller via Ajax in Blade
- → AJAX folder path issue
- → Onclick with argument causes javascript syntax error
- → KNockout JS - Automatic reload of ajax call
Ad