Release a super mini Ajax source code (including a simple framework)

Source: Internet
Author: User
I used ajax to build a GIS project two days ago. I wanted to use ajaxpro, but I couldn't find the source code. I wrote a similar project based on Huludao.

(Including simple frameworks and instances)
/Files/sukyboor/ajax.rar

Usage:
1. Add
<! -- Ajax -->
<Httphandlers>
<Add verb = "post, get" Path = "ajax/*. ashx" type = "Ajax. pagehandlerfactory, Ajax"/>
</Httphandlers>

2 ajaxtest. BR, ajaxtest indicates the business processing class
Add the Ajax. ajaxmethod () attribute to the method called on the client for this class

1 using system;
2 Using ajax;
3
4 namespace ajaxtest
5 {
6/** // <summary>
7 // a Summary of the BR.
8 /// </Summary>
9 Public Class BR
10 {
11
12 // obtain the table tablename data, which is returned as an XML string
13 [Ajax. ajaxmethod ()]
14 public static string showmsg ()
15 {
16 return "System Call return! ";
17}
18
19 // obtain the table tablename data, which is returned as an XML string
20 [Ajax. ajaxmethod ()]
21 public static string getxmldatarows (string T, string a, string B)
22 {
23 return string. Format ("<? XML version =/"1.0/" encoding =/"UTF-8/"?> <Doc> <t> {0} </T> </DOC> ", t );
24}
25}
26}
27

3. Add
<SCRIPT src = "ajax/common. ashx" type = "text/JavaScript"> </SCRIPT>
<SCRIPT src = "ajax/ajaxscript. ashx? Type = ajaxtest. BR, ajaxtest "type =" text/JavaScript "> </SCRIPT>
Note that the type of the ajaxscript. ashx file is the class to be called. If the type is set, all methods with Ajax. ajaxmethod () attributes in the class can be accessed on the client. <HTML>
<Head>
<SCRIPT src = "ajax/common. ashx" type = "text/JavaScript"> </SCRIPT>
<SCRIPT src = "ajax/ajaxscript. ashx? Type = ajaxtest. BR, ajaxtest "type =" text/JavaScript "> </SCRIPT>
<SCRIPT>


// The last parameter is the callback method. Triggered after interaction with the background
BR. getxmldatarows ('xt _ name_t ', 'A', 'test data', showmsg );
BR. getxmldatarows ('xt _ name_t ', 'A', 'test data', showmsg );

// Return value of Method s
Function showmsg (s ){
VaR Doc = new ajaxdom (s );
Document. Write (Doc. selectsinglenode ("DOC/t"). Text );
}

// If there is no callback method, the system will wait for the data to be read...
Document. Write (Br. showmsg ());
Document. Write (Br. showmsg ());
</SCRIPT>
</Head>
<Body>
</Body>
</Html>

This is easy. When I have time, I will port the data lifetime and some client components, as it is.

Http://sukyboor.cnblogs.com/archive/2006/07/21/456616.html

Related Article

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.