📄 hello world - dojo for the attention-impaired the dojo toolkit.mht
字号:
Please enter your name: <SPAN class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/input.html"><SPAN=20
class=3Dkw2><input</SPAN></A> <SPAN class=3Dkw3>type</SPAN>=3D<SPAN=20
class=3Dst0>"text"</SPAN> <SPAN class=3Dkw3>name</SPAN>=3D<SPAN=20
class=3Dst0>"name"</SPAN><SPAN class=3Dkw2>></SPAN></SPAN><BR> =
<SPAN=20
class=3Dsc2><SPAN class=3Dkw2></form></SPAN></SPAN></DIV><BR>
<P>Next we need to change the dojo/method:</P>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace"><SPAN =
class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/script.html"><SPAN=20
class=3Dkw2><script</SPAN></A> <SPAN class=3Dkw3>type</SPAN>=3D<SPAN=20
class=3Dst0>"dojo/method"</SPAN> event=3D<SPAN =
class=3Dst0>"onclick"</SPAN><SPAN=20
class=3Dkw2>></SPAN></SPAN><BR> =20
dojo.xhrGet({<BR> url:=20
'HelloWorldResponseGET.php',<BR> =
load:=20
helloCallback,<BR> error:=20
helloError,<BR> content: {name:=20
dojo.byId('name').value }<BR> });<BR><SPAN=20
class=3Dsc2><SPAN class=3Dkw2></script></SPAN></SPAN></DIV><BR>
<P>to:</P>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace"><SPAN =
class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/script.html"><SPAN=20
class=3Dkw2><script</SPAN></A> <SPAN class=3Dkw3>type</SPAN>=3D<SPAN=20
class=3Dst0>"dojo/method"</SPAN> event=3D<SPAN =
class=3Dst0>"onclick"</SPAN><SPAN=20
class=3Dkw2>></SPAN></SPAN><BR> // Don't forget to =
replace the=20
value for 'url' with<BR> // the value of appropriate file =
for your=20
server<BR> // (i.e. 'HelloWorldResponsePOST.asp') for an ASP=20
server<BR> dojo.xhrPost({<BR> =
url:=20
'HelloWorldResponsePOST.php',<BR> load:=20
helloCallback,<BR> error: =
helloError,<BR> =20
form: 'myForm'<BR> });<BR><SPAN =
class=3Dsc2><SPAN=20
class=3Dkw2></script></SPAN></SPAN></DIV><BR>
<P>As can be seen from the code above, we've changed dojo.xhrGet to=20
dojo.xhrPost. We removed the 'content' property and replaced it with a =
new=20
property 'form'. This basically informs the dojo.xhrPost function that =
it needs=20
to use the form 'myForm' as the source for the data in the call. </P>
<P>As with the last section, entering your name and clicking 'Hello =
World!'=20
should yield a message such as 'Hello <NAME>, welcome to the world of =
Dojo!'=20
where <NAME>is the name you entered into the text box.</P>
<H3>Using a PHP Server</H3>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace"><SPAN=20
class=3Dkw2><?php</SPAN><BR> <SPAN class=3DcoMULTI>/*<BR> =
*=20
HelloWorldResponsePOST.php<BR> * --------<BR> *<BR> * =
Print=20
the name that is passed in the<BR> * 'name' $_POST parameter in a=20
sentence<BR> */</SPAN><BR class=3Dgeshibr> <A=20
href=3D"http://www.php.net/header"><SPAN =
class=3Dkw3>header</SPAN></A><SPAN=20
class=3Dbr0>(</SPAN><SPAN class=3Dst0>'Content-type: =
text/plain'</SPAN><SPAN=20
class=3Dbr0>)</SPAN>;<BR> <A =
href=3D"http://www.php.net/print"><SPAN=20
class=3Dkw3>print</SPAN></A> <SPAN class=3Dst0>"Hello {$_POST['name']}, =
welcome to=20
the world of Dojo!<SPAN class=3Des0>\n</SPAN>"</SPAN>;<BR><SPAN=20
class=3Dkw2>?></SPAN></DIV>
<H3>Using an ASP Server</H3>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace"><SPAN=20
class=3Dkw2><%</SPAN><BR> <SPAN class=3Dco1>'</SPAN><BR> =
<SPAN=20
class=3Dco1>' HelloWorldResponsePOST.asp</SPAN><BR> <SPAN =
class=3Dco1>'=20
--------</SPAN><BR> <SPAN class=3Dco1>'</SPAN><BR> <SPAN =
class=3Dco1>'=20
Print the name that is passed in the</SPAN><BR> <SPAN =
class=3Dco1>' 'name'=20
$_POST parameter in a sentence</SPAN><BR> <SPAN =
class=3Dco1>'</SPAN><BR=20
class=3Dgeshibr> <SPAN class=3Dkw1>response</SPAN>.<SPAN=20
class=3Dkw3>ContentType</SPAN>=3D<SPAN =
class=3Dst0>"text/plain"</SPAN><BR> <SPAN=20
class=3Dkw1>response</SPAN>.<SPAN class=3Dkw3>write</SPAN><SPAN=20
class=3Dbr0>(</SPAN><SPAN class=3Dst0>"Hello "</SPAN> & <SPAN=20
class=3Dkw1>request</SPAN>.<SPAN class=3Dkw3>form</SPAN><SPAN=20
class=3Dbr0>(</SPAN><SPAN class=3Dst0>"name"</SPAN><SPAN =
class=3Dbr0>)</SPAN> &=20
<SPAN class=3Dst0>", welcome to the world of Dojo!<SPAN=20
class=3Des0>\n</SPAN>"</SPAN><SPAN class=3Dbr0>)</SPAN><BR><SPAN=20
class=3Dkw2>%></SPAN></DIV>
<H3>Using a ColdFusion Server</H3>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: =
monospace"><!---<BR> <SPAN=20
class=3DcoMULTI>/*<BR> * HelloWorldResponsePOST.cfm<BR> *=20
--------<BR> *<BR> * Print the name that is passed in =
the<BR> =20
* 'name' POST parameter in a sentence<BR> =20
*/</SPAN><BR>---><BR><cfsetting showDebugOutput=3D<SPAN=20
class=3Dst0>"No"</SPAN>><BR>Hello, #form.<SPAN =
class=3Dkw3>name</SPAN>#, welcome=20
to the world of Dojo!<BR></cfsetting></DIV>
<H3>Using a Java Server (JSP)</H3>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: =
monospace"><%<BR> <SPAN=20
class=3DcoMULTI>/*<BR> ' HelloWorldResponsePOST.jsp<BR> '=20
--------<BR> '<BR> ' Print the name that is passed in =
the<BR> =20
' 'name' POST parameter in a sentence<BR> */</SPAN><BR=20
class=3Dgeshibr> response.<SPAN =
class=3Dme1>setContentType</SPAN><SPAN=20
class=3Dbr0>(</SPAN><SPAN class=3Dst0>"text/plain"</SPAN><SPAN=20
class=3Dbr0>)</SPAN>;<BR>%><BR>Hello <%=3D request.<SPAN=20
class=3Dme1>getParameter</SPAN><SPAN class=3Dbr0>(</SPAN><SPAN=20
class=3Dst0>"name"</SPAN><SPAN class=3Dbr0>)</SPAN> %> , welcome to =
the world of=20
Dojo!</DIV>
<H3>Using a Perl Server</H3>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace">#!<SPAN=20
class=3Dre0>/usr/bin/</SPAN>perl<BR>#<BR># <SPAN class=3Dst0>'=20
HelloWorldResponsePOST.pl<BR># '</SPAN> --------<BR># <SPAN=20
class=3Dst0>'<BR># '</SPAN> <SPAN class=3Dkw3>Print</SPAN> the =
<SPAN=20
class=3Dkw3>name</SPAN> that <SPAN class=3Dkw1>is</SPAN> passed <SPAN=20
class=3Dkw1>in</SPAN> the<BR># <SPAN class=3Dst0>' '</SPAN><SPAN=20
class=3Dkw3>name</SPAN><SPAN class=3Dst0>' POST parameter in a =
sentence<BR>#<BR>use=20
strict;<BR>use CGI;<BR>my $cgi =3D CGI::new();<BR>print =
$cgi->header(-type=20
=3D> "text/html; charset=3Dutf-8");<BR>print "Hello " .=20
$cgi->param('</SPAN><SPAN class=3Dkw3>name</SPAN><SPAN class=3Dst0>') =
. ",=20
welcome to the world of Dojo!<SPAN class=3Des0>\n</SPAN>";</SPAN></DIV>
<H2>Finding more resources</H2>
<P>I hope you've enjoyed this tutorial and found it informative. No =
doubt=20
though, you will need more information on Dojo and how it and it's =
widgets work.=20
Below is a list of links that will point you in the right direction.=20
<UL>
<LI><A href=3D"http://dojotoolkit.org/docs/">The documentation =
page</A> for=20
Dojo. Has links to all documentation.=20
<LI><A=20
=
href=3D"http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic=
-dijit-and-dojo/event-system">The=20
Dojo event system</A>. How you can link functions to the normal JS =
events the=20
Dojo way.=20
<LI><A=20
=
href=3D"http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic=
-dijit-and-dojo/ajax-transports">Dojo=20
XmlHttpRequest</A> - The foundation for AJAX in Dojo.=20
<LI><A=20
=
href=3D"http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic=
-dijit-and-dojo/manipulating-widgets-through-code/writing-yo-0">The=20
File Upload Widget</A> - Widgets! Components! Does the complete tour =
of the=20
creation of a fully functional UI component and it's usage.=20
<LI><A href=3D"http://svn.dojotoolkit.org/dojo/dojo/trunk/tests/">Dojo =
Unit=20
Tests</A> from current nightly build (good for learning how things =
work)=20
<LI><A =
href=3D"http://svn.dojotoolkit.org/dojo/dijit/trunk/tests/">Dijit Unit=20
Tests</A> from the current nightly build (good for learning how =
widgets work)=20
</LI></UL>
<H2>Contacting the Author</H2>
<P>Thinking of making modifications to this document? Want to make =
suggestions /=20
constructive criticism?</P>
<P>If so, please contact me (Lance Duivenbode) at dojo AT duivenbode DOT =
id DOT=20
au. Feedback is always welcome since it helps me improve my =
documentation - both=20
now and in the future. Thanks!</P>
<H2>Changelog</H2>
<UL>
<LI>17th November 2007 - Pulled kicking and screaming into the Dojo =
1.0 era=20
(Craig Riecke)=20
<LI>28th June 2006 - Addition of Perl Server examples for GET and POST =
(courtesy of Gareth Tansey)=20
<LI>21th June 2006 - Modification for compatibility with 0.3.x release =
(Bill=20
Keese)=20
<LI>22th May 2006 - Addition of Java Server (JSP) examples for GET and =
POST=20
(courtesy of Kexi)=20
<LI>19th May 2006 - Addition of ColdFusion examples for GET and POST =
(courtesy=20
of Matthew Reinbold)=20
<LI>8th May 2006 - Initial Public Release </LI></UL>
<TABLE id=3Dattachments>
<THEAD>
<TR>
<TH>Attachment</TH>
<TH>Size</TH></TR></THEAD>
<TBODY>
<TR class=3Dodd>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/HelloWorldResponseGET.asp_.txt">=
HelloWorldResponseGET.asp_.txt</A></TD>
<TD>273 bytes</TD></TR>
<TR class=3Deven>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/HelloWorldResponseGET.php_.txt">=
HelloWorldResponseGET.php_.txt</A></TD>
<TD>253 bytes</TD></TR>
<TR class=3Dodd>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/HelloWorldResponseGET.pl_.txt">H=
elloWorldResponseGET.pl_.txt</A></TD>
<TD>327 bytes</TD></TR>
<TR class=3Deven>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/HelloWorldResponsePOST.asp_.txt"=
>HelloWorldResponsePOST.asp_.txt</A></TD>
<TD>267 bytes</TD></TR>
<TR class=3Dodd>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/HelloWorldResponsePOST.php_.txt"=
>HelloWorldResponsePOST.php_.txt</A></TD>
<TD>256 bytes</TD></TR>
<TR class=3Deven>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/HelloWorldResponsePOST.pl_.txt">=
HelloWorldResponsePOST.pl_.txt</A></TD>
<TD>329 bytes</TD></TR>
<TR class=3Dodd>
<TD><A=20
=
href=3D"http://www.dojotoolkit.org/files/response.txt">response.txt</A></=
TD>
<TD>16 bytes</TD></TR></TBODY></TABLE>
<DIV class=3Dbook-navigation>
<DIV class=3D"page-links clear-block"><A class=3Dpage-previous=20
title=3D"Go to previous page"=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9/part-1-life-dojo/quick-=
installation">=E2=80=B9=20
Quick Installation</A><A class=3Dpage-up title=3D"Go to parent page"=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9-0">up</A><A =
class=3Dpage-next=20
title=3D"Go to next page"=20
href=3D"http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-you=
r-dojo-code-run-faster-and-better/debugging-facilities/deb">Debugging=20
Tutorial =E2=80=BA</A></DIV></DIV></DIV>
<DIV class=3Dlinks>
<UL class=3D"links inline">
<LI class=3D"first book_printer"><A class=3Dbook_printer=20
title=3D"Show a printer-friendly version of this book page and its =
sub-pages."=20
href=3D"http://dojotoolkit.org/book/export/html/2994">Printer-friendly =
version</A>=20
<LI class=3Dcomment_forbidden><SPAN class=3Dcomment_forbidden><A=20
=
href=3D"http://dojotoolkit.org/user/login?destination=3Dnode/2994%2523com=
ment-form">Login</A>=20
or <A=20
=
href=3D"http://dojotoolkit.org/user/register?destination=3Dnode/2994%2523=
comment-form">register</A>=20
to post comments</SPAN>=20
<LI class=3D"last subscriptions_add_node"><A =
class=3Dsubscriptions_add_node=20
title=3D"Receive an e-mail whenever a comment is posted to this Book =
page."=20
href=3D"http://dojotoolkit.org/subscriptions/add/node/2994">Subscribe =
post</A>=20
</LI></UL></DIV></DIV>
<DIV id=3Dcomments><A id=3Dcomment-9405></A>
<DIV class=3Dcomment>
<H3 class=3Dtitle><A class=3Dactive=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9/hello-world-tutorial#co=
mment-9405">Post=20
Script Error</A></H3>
<DIV class=3Dsubmitted>Submitted by vanholy on Tue, 11/27/2007 - =
10:43.</DIV>
<DIV class=3Dcontent>
<P>The following script used for post method doesn't work:</P>
<P>
<DIV class=3Dgeshifilter><script type=3D<SPAN =
class=3Dst0>"dojo/method"</SPAN>=20
event=3D<SPAN class=3Dst0>"onclick"</SPAN>><BR> =
dojo.<SPAN=20
class=3Dme1>xhrPost</SPAN><SPAN class=3Dbr0>(</SPAN><SPAN=20
class=3Dbr0>{</SPAN><BR> url: <SPAN=20
class=3Dst0>'HelloWorldResponsePOST.jsp'</SPAN>,<BR> =
=20
load: helloCallback,<BR> error: =
helloError,<BR> =20
form: <SPAN class=3Dst0>'myForm'</SPAN><BR> =
<SPAN=20
class=3Dbr0>}</SPAN><SPAN class=3Dbr0>)</SPAN>;<BR></script></DIV>
<P><EM>event=3D"onclick" should be event=3D"on<STRONG>C</STRONG>lick" =
otherwise=20
nothing happens.</EM></P></DIV>
<DIV class=3Dlinks>
<UL class=3Dlinks>
<LI class=3D"first last comment_forbidden"><SPAN =
class=3Dcomment_forbidden><A=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -