Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Architecture for single page application (JavaScript)

I wanted to understand the overall architecture for designing single page application (mainly through JavaScript)

Let's say I have a login page (Usernam/Password) and on successful authentication, I am shown the homepage. Now both the login and homepage screens should actually be part of a single page.

How can I design such kind of page?

like image 265
copenndthagen Avatar asked Mar 06 '13 11:03

copenndthagen


People also ask

What is Single Page Application architecture?

An SPA (Single-page application) is a web app implementation that loads only a single web document, and then updates the body content of that single document via JavaScript APIs such as XMLHttpRequest and Fetch when different content is to be shown.

What is the architecture of JavaScript?

Typical JavaScript Application ArchitectureTypically, JavaScript applications use the bottom-up approach, always placing the User Interface (UI) at the center of the development at all times. As shown in the diagram, both the UI and the Server directly link to the code behind.

Which framework of JavaScript is most commonly used for building single page application?

Developed by Google, AngularJS is one of the open-source, front-end, JavaScript-based frameworks widely used in creating single-page applications on the client-side.


1 Answers

This is such a broad question that entire books could be written to answer it in detail.

Basically what you need to do is to use AJAX instead of page reloads. You still need to connect to the server to authenticate users but instead of reloading the entire page every time you do it, you need to make an AJAX call to your server and depending on whether the login was successful or not change some parts of the content on the page (like changing the Login button to a "Logged in as user xxx" message etc.).

like image 137
rsp Avatar answered Sep 21 '22 17:09

rsp