JavaScript DHTML/Mootools/Ajax
Содержание
Request HTML
<source lang="html4strict">
</source>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/Request.HTML.zip">Request.HTML.zip( 29 k)</a>
Request is the basic XHR request class in MooTools
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css">
- result {
width: 500px; padding: 10px; background-color: #F9F9F9; border-right: 1px solid #ccc; border-bottom: 1px solid #ccc;
}
</style> <script type="text/javascript" src="mootools.js"></script> <script type="text/javascript">
window.addEvent("domready", function(){
// You can skip the following line. We need it to make sure demos // are runnable on MooTools demos web page. var demo_path = window.demo_path || ""; // -- //We can use one Request object many times. var req = new Request({ url: demo_path + "data.txt", onSuccess: function(txt){ $("result").set("text", txt); }, // Our request will most likely succeed, but just in case, we"ll add an // onFailure method which will let the user know what happened. onFailure: function(){ $("result").set("text", "The request failed."); } }); $("makeRequest").addEvent("click", function(){ req.send(); }); $("failedRequest").addEvent("click", function(e){ //We can pass new options for our Request object to the send method. req.send({url:"/assets/not_here.txt"}); });
});
</script> <title>Request Demo</title>
</head> <body>
Request
Introduction
Request is the basic XHR request class in MooTools. While not extremely useful on its own, it provides the basic functionality for both Request.HTML and Request.JSON.
<a href="#" id="makeRequest" title="Make Request">Make Request</a> | <a href="#" id="failedRequest">This Request Will Fail</a>
Result
</body> </html>
</source>
Request JSON
<source lang="html4strict">
</source>
<A href="http://www.wbex.ru/Code/JavaScriptDownload/Request.JSON.zip">Request.JSON.zip( 30 k)</a>