In CI, how to make js call the variable controller in php: classIndexextendsCI_Controller {& nbsp; constrsp; construct () & nbsp ;{& nbsp; parent :: __construct (); & nbsp; load the url class and how to make js call the variables in php in the model CI
Controller:
Class Index extends CI_Controller
{
// Constructor
Function _ construct ()
{
Parent: :__ construct ();
// Load the url class and template parsing class
$ This-> load-> helper ('URL ');
$ This-> load-> library ('Parser ');
}
// Homepage (displays the Hefei area by default)
Function index ($ locat = 'hf ')
{
$ Data = array (
'Locat' => $ locat,
);
$ This-> parser-> parse ('index', $ data );
}
}
There is a js section in index. php under view and you want to call the value of the $ locat variable.
JQuery (function ($ ){
$ ("# Count_p"). parent ("p"). hide (); // remove
$ ("# Menu # $ locat"). attr ("class", "selected ");
});
This writing cannot be implemented. how can I write it? Wanggao zhijiao
------ Solution --------------------
// Homepage (displays the Hefei area by default)
Function index ($ locat = 'hf ')
{
$ Data ['locat'] = $ locat;
$ This-> parser-> parse ('index', $ data );
}
Var a = in js in view ;