Welcome Guest, Not a member yet? Register   Sign In
Load view into a variable?
#5

(03-05-2016, 03:25 AM)PaulD Wrote: Hi,

You are correctly using the 3rd term set to true in the load view function. This returns the view as a string for your variable.

PHP Code:
$result["view"] = $this->load->view('template/test'''TRUE); 

The second variable which you have left as an empty string is where you would pass the data to the partial view.

PHP Code:
$page_data = array('name' => 'mydata');
$result["view"] = $this->load->view('template/test'$page_dataTRUE); 

You can then access any of the array keys in your partial view as you would normally using, in the example above,

PHP Code:
My name is <?php echo $name?>

Hope that helps,

Paul.


Hi Paul,

can I perform jquery operation in test and set the value in view that value is not returned in $result["view"]

view Code

My Name is <?php echo $name ?>
<div id="address"></div>
<script>
$(function(){
    $('#address').html('this is my name print');
});
</script>

The $result["view"] will have contains the address div value. but I'm getting an empty value. 

Can you guide me on that?
Reply


Messages In This Thread
Load view into a variable? - by dysko - 03-01-2016, 05:25 PM
RE: Load view into a variable? - by albertleao - 03-01-2016, 09:10 PM
RE: Load view into a variable? - by pizzel - 03-01-2016, 10:57 PM
RE: Load view into a variable? - by PaulD - 03-05-2016, 03:25 AM
RE: Load view into a variable? - by Kailas Bedarkar - 05-28-2018, 02:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB