Answer the question
In order to leave comments, you need to log in
AJAX Pagination, what to get in response, JSON or HTML?
Hello.
I myself answer the back, but I work in conjunction with the front-end, the task is to make AJAX pagination. Those. the user presses the button "show more X products", and they are loaded to him. We had a dispute about how best to give me the data to him.
His point of view: he sends an AJAX request, and I return the HTML code of the next page to him, and he receives it and inserts it into the page
My point of view: he sends an AJAX request, I return the data to him in JSON, he parses it, and inserts it into the page .
Who is right and why?
Answer the question
In order to leave comments, you need to log in
I didn’t work with the back, but logically JSON is better, and let it parse it and generate html markup (this is the essence of the front - send a request, accept a response, and make a view from the response)
The back is not created in order to return HTML markup.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question