The first week of 1808 notes

 
http://javascript.ruanyifeng.com/advanced/promise.html promise Usage

4. promise talk effect, the basic encoding demonstrate promise
* hell solution callback (the callback deeply nested, expanding the right code is read poor)
var = new new promise Promise (function (Resolve, Reject ) {
// do asynchronous operation
if (success) {
Resolve (Result);
} {the else
Reject (errorMsg);
}
})
promise.then (function (
Result => the console.log (Result),
errorMsg => Alert ( errorMsg)
)

 
 Interview questions 
 encodeURIComponent methods have special characters such as (?, #, spaces, etc.) are encoded, will carry special characters? key = value, etc. For example, sometimes when the front-end data transfer, if not the background when receiving the encoding process, sometimes filtered out, resulting in background not receive data error. 

https://zccst.iteye.com/blog/2152750 there a similar method encodeURI (), this function almost. No encodeURIComponent powerful. We are coding method. Articles look

Interview questions: page encoding and encoding resources requested and if not how to deal with?
For the parameters ajax request is passed, if it is get request method, parameter, if passed Chinese, in some browsers garbled, different browsers on the parameters of the encoding process in different ways, so the parameters get requests need to use encodeURIComponent function parameters encoding process, background development language has a corresponding decoding api. For post requests need to code

To transfer information between different pages, there are several solutions:
(1) use a cookie, the login is successful, the server stores user information to the client's cookie. Such drawbacks:
① poor security, user information is stored locally, it is easy to find someone else.
② server each time you open a Web page, users can read information from the client through a network, such a waste of bandwidth when many users, each user opens a lot of pages, will be a huge waste of bandwidth.
(2) Road solution: session
the Session is a server-side technology, the server can create a file for exclusive session for each user's browser session due to the exclusive user's browser, so users access the web server resources , they can put their data on their own session, when users go to access other web server resources, and other web resources and then removed from the user data services for users in each session.
The biggest difference with the cookie: cookie is placed on the client, session is placed on the server!

Guess you like

Origin www.cnblogs.com/mo123/p/11139430.html