EllisLab text mark
Advanced Search
     
do ajax calls instantiate the controller and/or model ??
Posted: 18 November 2012 05:06 PM   [ Ignore ]
Joined: 2012-11-18
1 posts

Hi
I am using ajax (xmlhttprequest object) on a view to ‘GET’ from a controller

Model: News_model
View:  news_view
Controller: News


the constructor of the controller loads the model.

and the constructor of the model parses a xml file and puts the results in a db table.

the problem is that with every ajax call, the db table is getting filled with the parsed data again..
in other words: it seems like every ajax call is instantiating the controller and/or the model

is my question clear enough, or should I post some code?

P.S: I don’t want to use an ajax framework for CI, I have to use the xmlhttprequest

 

 
Posted: 18 November 2012 05:27 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3819 posts

Any request to the server that gets processed with CI will
-load anything that is autoloaded
-load anything that that particular controller loads
-execute anything in that controllers constructor (including any base controllers doing things)
-execute anything in that controllers method that was called

The problem is either with how you are sending the data (request) to the server or the logic in the controller not checking things properly and doing it (storing your data) again.

Beyond that - it’s all guesses with no code to see.

 Signature