CodeIgniter Forums
calling a function within a view? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: calling a function within a view? (/showthread.php?tid=15688)



calling a function within a view? - El Forum - 02-11-2009

[eluser]tjackson1982[/eluser]
Hello all,

I'm hitting a wall. I'm trying to combine mootool ajax with CI and it doesn't seem to be working.

very simply I'm doing something like this.

Code:
<div id="headlines">

"<"script language="JavaScript"">"

$('headlines').load('index.php/Display/display_headline/');

"<"/script">"

</div>

basically I'm trying to capture the output of a function and just load the html returned and place it in that element.

Is this even possible? If not how can I do something similar? please simple examples...

Thanks,
Tom J.


calling a function within a view? - El Forum - 02-11-2009

[eluser]majidmx[/eluser]
put the function in a library or plugin and easily call it from the View.
Like this :

Code:
$('headlines').load('&lt;?PHP echo my_lib_func();?&gt;');

Let me know if I got the idea wrong.


calling a function within a view? - El Forum - 02-11-2009

[eluser]tjackson1982[/eluser]
I'm looking into it right now, but might take me some slight time to see if it is what I need.

Thanks for the suggestion.
Tom J.