Welcome Guest, Not a member yet? Register   Sign In
How to set and access global variable through controller functions?
#3

(09-14-2019, 12:43 PM)Wouter60 Wrote: Ajax is used to run a server sided script from a view (not from a function in a controller), and most times return information to the view and update the DOM without refreshing the page. You'll have to rely on Javascript to do that (that's the j in Ajax).

What you can do, is pass the page_id to the view (from your "view" function). Put the Ajax function in that view to run the "groups/anotherFunction" function. The view knows the page_id, so it can pass it (by get or post) to "anotherFunction".
Don't make "anotherFunction" load another view, but let it echo the information that you want to get in the original view.

There's lot of Ajax examples combined with CodeIgniter out there on the internet, e.g. on StackOverflow.

Yeap i'm familiar with Ajax.

As for loading a second view with anotherFunction, that's because i've created a calendar with dynamic data in each cell. So it's kinda complicated to return them as json encoded data. Moreover i have tabs which (after clicking the button) the ajax pass data with get to anotherFunction (page_id and some other stuff) and returns the filtered data in the view.
I hope you understood what i've tried to do here.

As for the last one, i've searched a big amount of pages and the best i found was to place a hidden input somewhere in the "view" page and then pass the parameters in controller with ajax.

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply


Messages In This Thread
RE: How to set and access global variable through controller functions? - by HarrysR - 09-14-2019, 12:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB