问题
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