Welcome Guest, Not a member yet? Register   Sign In
Formatting asynch feedback callbacks and handling them within the view
#1

[eluser]andyy[/eluser]
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?
#2

[eluser]InsiteFX[/eluser]
With custom rewrite of session libraries.

InsiteFX
#3

[eluser]byde[/eluser]
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
#4

[eluser]andyy[/eluser]
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?
#5

[eluser]InsiteFX[/eluser]
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.

InsiteFX
#6

[eluser]andyy[/eluser]
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.
#7

[eluser]InsiteFX[/eluser]
It is a session problem that effects all the session libraries.

InsiteFX
#8

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

InsiteFX[/quote]

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: .




Theme © iAndrew 2016 - Forum software by © MyBB