I am pretty new to Web Application programming and so to OOP Javascript and the
ID: 646773 • Letter: I
Question
I am pretty new to Web Application programming and so to OOP Javascript and the new Client-Server interactions. I am encountering some trouble wondering about how much AJAX I should use or how much data I have to save "locally" . Explainig it better: at the moment , to manage the data that I obtain from AJAX request , I push them in Data Structure like Array's and then I handle them helping myself rendering html through template. Now, was I wondering : is all this necessary? Do I really need to store all this data in Data Structures or I can make AJAX call for every action users do on my application? I apologize for the explanation but it's a difficult concept for me to explain in English. Thanks in advance
Explanation / Answer
It is not cut and dry but it should be a simple rule of thumb. If the page "needs" the data then embed it in the page. Needs would mean that no matter what action the user does the data is needed to perform that action.
For example the page is a grid that has a list of orders, the order data is needed to populate the grid which is the only item on the screen. It would make sense to embed the data. Now if the user clicks a row and a popup appears with more data that should probably be done with an ajax request cause the user may or may not see the popup.
The only situation where I wouldn't embed the page when it is need would be if the data takes a very long time to generate. No user would tolerate a url request that takes 5+ seconds to come back. A quick response and a loading mask would be more acceptable.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.