I understand that Ajax reaches out for content on a server, but is this content be generated by user input? Let's say for instance when they buy something and it's "added up" by server-side code. Can that server-side code create the AJAX content? I ask because I can't imagine having content prepared for every event and scenario.
Asked
Active
Viewed 26 times
0
-
2Yes, a server can respond to a request however it wants. It can consider any, all, or none of the parameters of your request and can send whatever it wants back as a response. AJAX is more or less the same as any other request except it doesn't explicitly block while you're waiting for the response. – zero298 Dec 29 '15 at 17:15
-
1**Normal surfing in sites:** user types in url or clicks a link, connection is made between browser and server, request is sent, server processes request and _builds_ the page, then page / data is sent back to PC, new page is loaded and connection is closed. **AJAX:** request is sent via ajax, page is not refreshed, data is processed in server and data is sent back and page is updated via jQuery / JS because there's no way to change page without refreshing it otherwise. By the end of the day both basically do the same thing only that one can be done without refresh. – Solo Dec 29 '15 at 17:19
-
1Regarding your edit (which I think leaves your question too broad still): Yes, servers can generate content. In the same way they can generate any other page - think of the questions here on SO - someone hasn't had to sit there and hand craft each and every page, they're generated based on database content on the server. The exact same goes for data returned via ajax calls. – James Thorpe Dec 29 '15 at 17:21