AJAX, form form validation

A basic json

 

 

 

Qualified json objects:

["one", "two", "three"]
{ "one": 1, "two": 2, "three": 3 }
{"names": ["张三", "李四"] }
[ { "name": "张三"}, {"name": "李四"} ] 

 Failed json objects:

{Name: "San", 'Age': 32}   // property name must use double quotes 
[32, 64, 128, 0xFFF] // not use a hexadecimal value of 
{ "name": "San", "Age": undefined} // can not use the undefined 
{ "name": "Joe Smith", 
  "Birthday": a Date new new ( 'Fri, 26 is-Aug 2011 07:13:10 GMT'), 
  "getName": function () return this.name {;}   // objects can not use functions and date 
}

 

Method 1. stringify and parse

JSON.parse (): for the character string into a JavaScript object JSON 

JSON.parse('{"name":"Q1mi"}');
JSON.parse('{name:"Q1mi"}') ;   // 错误
JSON.parse('[18,undefined]') ;   // 错误

JSON.stringify (): value for converting JavaScript JSON string. 

JSON.stringify({"name":"Q1mi"})

Two AJAX

AJAX ( Asynchronous Javascript And XML ) translated into Chinese is " asynchronous Javascript and XML" . That the use of Javascript language to interact with the server asynchronous data transmission for XML (Of course, data transmission is not just XML ).

AJAX is not a new programming language, but a new method to use existing standards.

The biggest advantage is AJAX without reloading the entire page, you can exchange data with the server and update parts of the page content. ( This feature is the feeling to the user request and response process is completed unknowingly)

AJAX does not require any browser plug-ins, but requires the user to allow the execution of JavaScript in the browser.

  • Synchronous interaction: The client sends a request, it must wait for the end of the server response before sending the second request;
  • Asynchronous interactions: the client sends a request to the server without waiting for the end of the response, it can issue a second request.

 

Guess you like

Origin www.cnblogs.com/mushuiyishan/p/11613952.html