[Note: For convenience, JavaScript is referred to as JS]
During the development of the ASP network application, I will get rid of the behavior of JS from a pure client environment, starting with another way: JS scripts for the server application.
I don't want to discuss how to use the COM service objects such as Application, Session, Request, Response, and ADO to combine the VBScript (or JS) scripting language for server programming, and do not want to make the VBScript and JS of the browser's scripting language. Dish, just simply talk about a little experience in which JS has been developed in the ASP program as a client script language.
In order to reduce the pressure of the server processing data, the large number of forms (FORM) data submitted to the server must be verified by processing or validity for the client, and the string and array objects in the JS are very performed during the processing of these data. Good choice, and Array objects store various types of data (from basic numeric to strings to object types) often let me suspect whether the Carray template class in MFC is being used, remember to return the server again. Multiple string data performs loop processing of queues, and then returns the data to the server, using the stack of Array objects, so that I can easily solve this problem. Analysis and verify the true expression rules such as email addresses, ID, telephone numbers, text box input characters, etc. Previous usual practice is endless if ... Else or while judgment, now use the regexp object Verify that the code correctly expresses the rule not only refinery but also very effective (of course, the syntax of regexp is also the most critical, and the processing is not easy to fall into the trap).
Some seemingly unacceptable grammar, actually use frequencies in JS very high, take an example, similar to a string "abcde", to find "c" is the first character, I can write: "abcde". IndexOf ("C"), a unique way of writing, and new string ("abcde"). IndexOf ("c") can also implement this function. Although I didn't accept these grammar at the beginning, the more JS scripts that write the client, the more I used these syntax, and it is very beneficial to the readability and maintenance of the program. JS's soul is on simply refining (please remember, not simple).
In the development of server-oriented applications, using JS to write DHTML documents is very necessary, one of my actual cases: users need to generate uncertain, large reproducible HTML tables according to their own requirements, and each table Contains many FORM controls. Imagine, if this thing is done by the ASP server script, what will be a situation? First, the user said that I have to generate 5 tables. After the server receives this request, first define a table template, then dynamically generate 5 tables in the server, and finally returns the HTML document required by the user. When as the increase of the number of request users and the number of tables requested, the server's load will not be guaranteed. If the same method is used by JS to dynamically generate these forms in the client, it will be a very wonderful thing. The specific rule is a JS operational DOM (document object model), generating a dynamic form.
Object-oriented features make me feel that I don't need to be objects in the client's DHTML development? JS is not a pure object-oriented language, although it can achieve or pseudo-oriented language-oriented language, these things are often used in DHTML? As mentioned in the "JavaScript Full Reference" I have seen: Most JS programmers use a rapid pulsed programs. My principle is: use process-oriented JS programming, none to object-oriented methods! Elementary point, in many practical applications, the sacrificial process-oriented programming is barely adopting object-oriented ways sometimes it is just right. Today, ASP.NET is hidden from the details of the client-oriented client, but I will never forget a flexible, efficient and very robust client, if I lose JS, then I lost the real charm of the web development. .
This essay has not yet true ends, let it stop first, and start with more understanding of JS at the same time :)
Yjgx at 2004-2-27 22:00