How to make js call of variables in php in CI

Source: Internet
Author: User
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 ;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.