The right compromise between “browser speed” and “respecting the model”

三世轮回 提交于 2019-12-25 02:29:17

问题


I've been creating a Google Maps API MVC5 application for the past weeks.

I know that I should keep all the logic inside the controller, but I have the following doubt: In my main View I have a button called "Avoid tolls". By pressing that button the user will see the route distances calculated previously in the controller (both with and without tolls).

My question is: Why should I get the route's distances in the controller (xml service) with and without tolls when I could do that inside the View ONLY if the user wanted to check the route distance without tolls? I feel I'm loosing time accessing information (xml service) that most likely will not be demanded by the user.

Perhaps there's a way to make the view go back to the controller by the time the button is pressed. Is that it?

Thank you!


回答1:


you can hook the button upto an ajax request in javascript and request the additional info from the server then update your view based on the result.



来源:https://stackoverflow.com/questions/21934684/the-right-compromise-between-browser-speed-and-respecting-the-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!