Prototype is an Open-source JavaScript development framework that encapsulates a number of ways to speed up development, such as using $ (' div ') instead of getElementById ("div"), encapsulating XMLHttpRequest, and so on. Many language development frameworks such as Ruby on Rails, Symfony (PHP) are integrated Prototype, there are many such as script.aculo.us, Rico, behaviour such derivative works, greatly expand the Protopype function, very Easy to implement automatically, element drag, flashing tips, rounded rectangle tip box, text fade, and other functions. Make the page "move" up, greatly improve the user experience. For the designer, the time spent on the UI has been greatly reduced, and the previous need for a long script code to achieve an effect may now take only one or two lines.
In Prototype, there are mainly two methods to implement asynchronous data transmission, respectively, Ajax.updater and Ajax.request.
[Copy to Clipboard] Code:function getcontents ()
{
var request_url = "test1.html"; The URL that needs to get the content
var request_pars = ';//Request Parameters
var myajax = new Ajax.updater (' result ', request_url,{//To bind Request_url return content to a container with ID result
Method: ' Get ',//http request, get or post
Parameters:request_pars,//Request parameters
Onfailure:reporterror,///When failure calls the ReportError function
Onloading:loading,//When the content is being obtained
Oncomplete:done//Content acquisition complete
Evalscripts:true
});
}
function loading ()
{
$ (' loading '). style.display = ' block ';
}
function done ()
{
$ (' loading '). Style.display = ' None ';
}
function ReportError (Request)
{
Alert (' Sorry. There is an error. ');
Ajax.updater provides us with three states for loading documents, oncomplete,onloading, OnFailure. We can customize a function corresponding to these three different states, so this feature, we can make a very cool like Gmail loading hint
prototype1.3.1 version of the developer manual. html
prototype1.4 version of the developer manual. html
Click to download this file 1.6
Click to download this file 1.5.1.1
Kjell Bublitz publishes Prototype chm API documentation and script.aculo.us reference documentation (including CHM, PDF format).
CHM: Click to download this file
Online API Documentation: HTTP://WWW.PROTOTYPEJS.ORG/API