Ajax. updater Application
Through this JS class library, AJAX technology will be easily applied Ajax. updater Application New Ajax. Updater ('id', "url", {options }); Id: id of the target to be updated Url: the operation you want to perform, or cgi Options: Default attribute type description Method Array 'post' HTTP request method. Parameters String ''list of url format values passed in HTTP requests. Asynchronous Boolean true specifies whether to perform asynchronous AJAX requests. PostBody String undefined transmits the content in the Request body in the case of http post. RequestHeaders Array undefined: the HTTP header list that is passed in with the request. This list must contain an even number of items. Any odd number of items is the name of the custom header, the following even number of items causes the string value of this header item. Example: ['my-header1', 'This is the value', 'My-other-header', 'Another value'] OnXXXXXXXX Function (XMLHttpRequest) undefined is the custom method called in an AJAX request when the corresponding event/status is formed. For example, var myOpts = {onComplete: showResponse, onLoaded: registerLoaded};. This method will be passed into a parameter, which is an XMLHttpRequest object carrying AJAX operations. Onsuccess function (XMLHttpRequest) undefined the custom method called when the Ajax request is successfully completed. This method will be passed in a parameter, which is an XMLHTTPRequest object carrying Ajax operations. Onfailure function (XMLHttpRequest) undefined the custom method called when the Ajax request is completed but an error occurs. This method will be passed in a parameter, which is an XMLHTTPRequest object carrying Ajax operations. Insertion function (object, string) null is a method executed to inject the returned text into an element. This method will be passed in two parameters, the object to be updated and only applied to the response text of Ajax. Updater. Evalscripts Boolean undefined and false determine whether to execute the script block when the response arrives, and apply it only in the Ajax. Updater object. That is, the JS Code of the target object must be set to true. Decay number undefined, 1 determines that when the last response and the previous response are both in Ajax. the number of times that the periodicalupdater object reduces the number of man access. For example, if it is set to 2, the object will wait for the second set interval to refresh the same as the previous result, if it is the same again, it will wait four times. If you do not set this parameter, or set it to 1, the Access frequency will be reduced. (Reference https://compdoc2cn.dev.java.net/prototype/html/prototype.js.cn.html#options_reference) Simple Example: I: Index.html: <Body> <script language = "javascript" src = "js/prototype. js "> </script> <script language =" javascript "> function doajax () {var ajax = new Ajax. updater ('My, "ajax. thtml ", {onComplete: function () {}, evalScripts: true });} </script> <div id = "my"> </div> <input type = "button" value = "click"> Ajax.html <Body> <script language = "javascript"> test = function () {alert ("OK") ;}</script> <div style = "border: 1px silver solid; "> using ajax! <Input type = "button" value = "gettest"> </div> </body> Note: To run the test () method in ajax.html, you must first set evalScripts: true, and then change the name of the test function to "function name = function. In addition, you can also run JSS in front of index.html without modifying the function. II: Forms can be submitted in a fresh way. <Form action = "/action/here" method = "post"> The above code is displayed on wiki. script. aculo. us. If you are interested, go to the original article. |