The basics of Dojo (ii) read data from the server _dojo

Source: Internet
Author: User
This example follows the content of the "Dojo Basics"
First, we create a new file in the same level directory in helloworld.html, named response.txt,内容为:

Welcome to the Dojo Hello world Tutorial

Replace the code for section 2 with the following code

 
 <!--section 3 
<script type= "Text/javascript"
Dojo.require ("dojo.io.*");
Dojo.require ("dojo.event.*");
Dojo.require ("dojo.widget.*");
Dojo.require ("Dojo.widget.Button"); The

//binding URL path. Of course, when the button is pressed, the request is sent to the Response.txt, at which point the server
//will return the content in Response.txt. This URL can be another object. Like the
//*** in struts . Do or is a servlet URL.
Function hellopressed ()
{
Dojo.io.bind ({
URL: ' response.txt ',
Handler:h Ellocallback
});
}

//process functions that return data. The three parameters are required .
Function Hellocallback (type, data, evt)
{
if (type = = ' ERROR '
Alert (' Error when retrieving data ' server! ');
Else
Alert (data);


Function init ()
{
var Hellobutton = dojo.widget.byId (' Hellobutton ');
Dojo.event.connect (Hellobutton, ' OnClick ', ' hellopressed ')
}

Dojo.addonload (init);
</script>
The above is all code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.