javascript jquery ajax 代写-LOPMENT 3403
时间:2021-05-30
1st SEMESTER EXAMINATIONS AGILE WEB DEVELOPMENT 3403 19 CITS3403 Sample Solutions 1. • Models: a user and a todo model are needed to provide the schema and ensure persistent storage of the user data and todo list. • Controllers: then a user controller needs have functions to support user registration and user au- thentication. A todo controller is needed to search the database and render a view to display a list of todos, when the user is successfully logged in. • Views: the view files will have forms and hyperlinks to generate the correct HTTP actions. Submit a form should be POST, a hyperlink can be associated with get or delete action. • Routing: these HTTP verbs combined with the URL are routed to the relevant controller functions for retrieving related data from the database and sending to the view files for rendering and displaying results back to the user. • Overall, GET request sent to server, the default route of a home page is the authentication page, which is constructed and sent to the client. The client then enters their email and password which is hashed and salted, and sent as a javascript object to the server using a post request to login. This matches a route and the JSON object is turned into a query using mongoose, which authenticates the user by looking for matching username and password. A Mongo query is made to get all the todo jobs of that user, which is returned as a JS object. This object is passed to a template (pug/jade/ejs) and rendered into a html page which is then sent to the client. 2. CSS linked file (external style sheet), CSS in the head (document-level style sheet) and inline CSS. Linked file most reusable and maintainable. In the head is limited to a single page and for inline, you can see its effect in context, but style is not separated from content. 3. • Document object model: language neutral platform and language neutral interface that will al- low programs and scripts to dynamically access and update the content, structure and style of documents. 1st SEMESTER EXAMINATIONS AGILE WEB DEVELOPMENT 3403 20 CITS3403 • Javascript object notation: a lightweight) Login br a(href="/register") Register if (user) h1= title h3 Welcome #{user.name} #[a(href= ’/logout’) Logout] each movie in user.movies .movie li= movie.title -var n = 0 -var stars = 0 each review movie.reviews if review.author=user.name n = review.stars - break while n < stars n++ img(src=’star.jpg’) 10. SPA does client side rendering using angular/react etc to render client side models. Two way data-binding synchronises the client side model with the server side database via an API. A web app hat uses server side rendering receives requests from the client and constructs an html document for the client to display, and delivers the entire document to client for every request. SPA’s can take longer to load but are more responsive and put less load on the server. Navigation can be challenging too (reloads etc). SSR is faster initially, but puts more load on the server.


























































































































学霸联盟


essay、essay代写