Welcome Guest, Not a member yet? Register   Sign In
AJAX & CI Controllers
#1

[eluser]gte451f[/eluser]
Hi Gang,

I've run into a design question that has stumped me so I wanted to put my question out to your collective wisdom.

I've designed a CI app where a web page will send AJAX requests to various controllers to perform CRUD operations and return HTML snippets that refresh the calling web page.

So if someone hits the delete button, ajax hits a delete function to:
1)remove the record and
2) return HTML snippit with which to update the original page.

The problem I'm running into is that I find my self on one page but need to call CRUD functions associated with another controller yet return HTML from the original calling controller.


So how to resolve this issue?

Can I call a controller from inside another controller?
I hear this is a bad idea and I'll be branded an MVC heretic. That and CI won't do this, that I know.

Must I put view related logic in a separate library?
In which case, my controllers are getting pretty insignificant if they can't even marshal data and return views since I may need to use that logic from a variety of controllers.

Should I never make ajax calls to controllers different than the controller that rendered a page?
That's gonna make form some large Frankenstein like controllers where they manage all sorts of CRUD operations for various tables even if they are just kicking the work off to underlying models.

How about 2 Ajax calls? One for CRUD to whatever controller followed by a 2nd ajax call to refresh the original page.
meh...this one is slightly better, but now I make 2 ajax calls everytime I need to do something on a web page.

Ok, let's test out the wisdom of crowds. Guide me oh wise CI community!


Messages In This Thread
AJAX & CI Controllers - by El Forum - 01-08-2013, 07:01 AM
AJAX & CI Controllers - by El Forum - 01-09-2013, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB