Formatting asynch feedback callbacks and handling them within the view

I'm curious as to how other developers are handling asynch callbacks (format and structure) and how you are handling them within the view itself.

For example, I like to encode my callbacks with php's json_encode() and process them with javascript. A typical json callback will contain a self assigned 'type' (value = 'info', 'error' or 'success') and the actual 'message'. I can decide on what type of a class to apply to my callback div based on the message type.

How are you doing it?

With custom rewrite of session libraries.


well, if i need just a status i use true/false or numbers (0 false, 1 true, 2 may be, 3 i dont care), if more info is required (like a table) i use json.

im not sure if this is what you are looking for

Thanks for the response guys. Right now I'm trying to find the most efficient and clean way of handling different types of callbacks within the view depending on how they were formatted by the backend (a response for all of the books in a library will be different then the result that is returned if the user requests items on a menu).

Do you create a single javascript function to handle any type of json/xml response? How do you assign what elements to target with the feedback without creating multiple functions?

I'm struggling with finding a quality solution as of right now.

@InsiteFX: could you elaborate a little more on your solution?

I cannot remember where it is on the forums but it has been mentioned about the session library not being able to handle Ajax Async calls. What happens is it over runs the sessions I think WanWizard had a solution for this by a custom session library.

For example your making Ajax Async calls one after another while your doing this the session library decides its time to regenerate the session_id so your next call will fail.

Try searching the forums I know there was some users talking about it.


Are you referring to the default session library that runs with database support? I always use the modified session library that uses native php sessions Smile.

I thought you were talking about a method to handle asynch calls using a custom session library.

It is a session problem that effects all the session libraries.


[quote author="InsiteFX" date="1301627234"]It is a session problem that effects all the session libraries.


Hmmm, interesting. I'll have to test this and keep it in mind but it really doesn't pertain to this threads topic.

Anyone else want to share their method of handling ajax asynch calls within the view?

I actually started developing a small systematic set of functions and rules to keep things tidy :cheese: .

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.