5
Good afternoon, I am implementing an infinite list in Asp net mvc and I have some questions about what is the best way to do this. I implemented using partial view, making a request via ajax and return this partial view and give an append to my html and it works well. But I also saw that it is possible to do this by returning a JSON with the data and assembling it via javascript and displaying to the user, what would be the best way? JSON or partial view?
It’s the "same" thing only instead of making a request per page, returning the rendered html to be displayed, you would do the same thing with a Json and let Javascript build this html. Or you make a single request to bring all the content of that page to JSON and only control the view
– Leandro Angelo
Partialview is already ready to do the append, if you receive the
json
return should be faster and lighter, but you will have to generate all html in javascript, you decide :)– Ricardo Pontual
So the two forms are correct, maybe with json get a little faster, beauty was just what I wanted to know, I’m a little engaged with performance and good practices
– Rafael Scheffer
Even if it comes as json, you’ll still get the processing to assemble the html and give it expensive append. The difference is that if you bring all the JSON at once, you will get an unnecessary load of information that may never be displayed. If you use a partialview and give append, it will be faster, because if you look at the implementation of the engine of Razor, you will see that it is well done mounting html. : ) Everything has a cost, whether processing (client or server) or network (transfer more data). Be engaged with performance, but not so much if it’s not a critical issue.
– Gustavo Santos
that’s how I’m doing, I load every 30 items and every time I need to fetch more, I’ll pick up the current position and look in the bank from that position
– Rafael Scheffer