Đang chuẩn bị liên kết để tải về tài liệu:
Ajax in Action phần 3

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Các văn bản của một phần tử có thể được theo kiểu về màu sắc, kích thước phông chữ, nặng nề của phông chữ và kiểu chữ để sử dụng. Nhiều tùy chọn có thể được quy định cụ thể đối với các phông chữ, để cho phép suy thoái duyên dáng trong các tình huống | Third-party libraries and frameworks 107 Then we merge the two to provide a single object containing all of the required behavior var parent new Vehicle 24 100 var extension new CarriagePuller 12 var passTrain Object.extend parent extension Note that we define the parent and extension objects separately at first and then mix them together. The parent-child relationship exists between these instances not between the Vehicle and CarriagePuller classes. While it isn t exactly classic object orientation it allows us to keep all the code related to a specific function in this case pulling carriages in one place from which it can easily be reused. While doing so in a small example like this may seem unnecessary in larger projects encapsulating functionality in such a way is extremely helpful. Prototype also provides Ajax support in the form of an Ajax object that can resolve a cross-browser XMLHttpRequest object. Ajax is extended by the Ajax.Request type which can make requests to the server using XMLHttpRequest like so var req new Ajax.Request myData.xml The constructor uses a style that we ll also see in many of the Prototype-based libraries. It takes an associative array as an optional argument allowing a wide range of options to be configured as needed. Sensible default values are provided for each option so we need only pass in those objects that we want to override. In the case of the Ajax.Request constructor the options array allows post data request parameters HTTP methods and callback handlers to be defined. A more customized invocation of Ajax.Request might look like this var req new Ajax.Request myData.xml method get parameters name dave likes chocolate rhubarb onLoaded function alert loaded onComplete function alert done n n req.transport.responseText The options array here has passed in four parameters. The HTTP method is set to get because Prototype will default to the HTTP post method. The parameters array will be passed down on the querystring because we