i have a php file in which i am calling external takeatour.js file in that js file i want php session data.by using a code....
$(this).ready(function() {
var category = <?php echo json_encode($this->session->userdata('category')); ?>;
alert("category="+category);
});
is it correct?? plz give me some suggestion. Thanks!!
SESSIONechothe value so it'll be present in the HTML to be available from javascript. Client doesn't have direct access to PHP variable, but you can ask the server (ajax for example) for the value..phpextension..jswill not executephp.