Wordpress offers wp_localize_script() function to assign some value from php to Javascript. This wp_localize_script() function makes any php data that's directly available in JavaScript.
Where $handle – refers to script file
$name – refers to name of the JavaScript object.
$data – where we can specify list parameters for that JavaScript object ($name) going to have.
For example I want following php data you want in ajax.js file. So we need to do following things.
While your page is excuted it will generate following scripts in your page.
So we can easily access that php data in JavaScript like below.
To know more about please refer following Wordpress Forntend Login Tutorial.
Where $handle – refers to script file
$name – refers to name of the JavaScript object.
$data – where we can specify list parameters for that JavaScript object ($name) going to have.
For example I want following php data you want in ajax.js file. So we need to do following things.
While your page is excuted it will generate following scripts in your page.
So we can easily access that php data in JavaScript like below.
To know more about please refer following Wordpress Forntend Login Tutorial.
Light Weight WordPress Frontend Ajax Login and Registration
0 comments:
Post a Comment