JAVASCRIPT is an indispensable part of AJAX technology. Therefore, it is most important to learn JAVASCRIPT well if you want to learn AJAX well and the popular AJAX framework. This chapter provides you with some basic JAVASCRIPT knowledge, common code, and event summary. I have sorted out some common JS methods, including verification, full selection, reverse selection, and ajax requests. Because they are used by myself, they are easy to write, if you like it, just pull it. If you don't like it, just pull it.
Tools. min. js
/*** JS public class library file * Creation Time: * created by: mction */(function () {var D = document; var W = window; var Postfix = '. php 'var _ Id = function (Id) {return document. getElementById (Id) ;}; Check = {Input: function (Name, Value, Message) {var Input =$ (": input [name = '"+ Name +"'] "); if (Input. val () = Value) {Input. focus (); alert (Message); return true;} return false;}, Phone: function (Name) {/** Unicom segment: 130/131/132/155 /156/185/186/145/176; * telecommunications segment: 133/153/180/181/189/177; * mobile segment: 134/135/136/137/138/139/150/151/152/157/158/159/182/183/184/187/188/147/178 */var Reg =/^ 1 (30 | 31 | 32 | 55 | 56 | 85 | 86 | 45 | 76 | 33 | 53 | 80 | 81 | 89 | 77 | 34 | 35 | 36 | 37 | 38 | 39 | 50 | 51 | 52 | 57 | 58 | 59 | 82 | 83 | 84 | 87 | 88 | 47 | 78) [0-9] {8} $/; var Phone = $ (": input [name = '" + Name + "']"); if (! Reg. test (Phone. val () {Phone. focus (); return true;} return false;}, Email: function (Name) {var Reg =/^ [a-zA-Z0-9 _] + @ [a-z0-9] + \. [a-z] + $/; var Email = $ (": input [name = '" + Name + "']"); if (! Reg. test (Email. val () {Email. focus (); return true;} return false;}, UserName: function (UserNameMark, Message) {var Reg =/^ [\ d] {8} $ /; var UserName = $ (": input [name = '" + UserNameMark + "']"); if (! Reg. test (UserName. val () {UserName. focus (); alert (Message); return true;} return false;}, Password: function (Name) {var Reg =/^ ([A-Z] +) $ | ^ ([a-z] +) $ | ^ ([0-9] +) $ | ^ ([-'=\\ [\];', \. \/~! @ # \ $ % \ ^ & \ * \ (\) _ + \ |\{}: "<>\?] +) $ | ^. {0, 5 }$ | ^. {18, }$/var Password = $ (": input [name = '" + Name + "']"); if (Reg. test (Password. val () {Password. focus (); return true;} else {return false ;}}; Member = {Login: function () {var UserName =$ (": input [name = 'username'] "); var PassWord = $ (": input [name = 'Password'] "); if (Check. userName ("username", "Incorrect UserName format") {return false;} if (Check. input ("password", ''," password cannot be blank ") {return false ;}$. ajax ({ Url: "/User/action" + Postfix, type: "POST", data: {request: "Login", username: UserName. val (), password: PassWord. val ()}, dataType: "json", success: function (Data) {if (Data. state! = 200) {alert (Data. message); return false;} else {location. href = "/User/member" + Postfix ;}}) ;}, Logout: function () {location. href = '/User/logout' + Postfix; }}; Public = {Hi: function () {alert ('Hi') ;}, Box_All_Sel: function (Class, AllChecked) {// select all var Input = D. getElementsByTagName ("input"); var BoxList = []; for (I = 0; I
These are the basic knowledge of JAVASCRIPT. If you are a newbie, I don't think you are enough to learn about it. You can find some complete information to learn about JAVASCRIPT.
For those who already have some JAVASCRIPT basics, You can first look at this knowledge, maybe you have forgotten or missed it, recalling JAVASCRIPT, it will be of great help for you to continue to learn about AJAX later.