Examples of ASP. NET Ajax and Jquery Ajax, jqueryajax

Source: Internet
Author: User

Examples of ASP. NET Ajax and Jquery Ajax, jqueryajax

In the library information management system, Ajax and JQueryAjax are all used. At the beginning, I was a stranger and was too late to start using it. However, you won't be able to make it happen when you don't do it. Go online and find an example. Of course, there were some minor errors in the middle, and they finally succeeded.

Ajax

AJAX (AsynchronousJavascript And XML) is a web page development technology used to create interactive web applications. By performing a small amount of data exchange with the server in the background, Ajax can implement asynchronous updates on the webpage, which means that a part of the webpage can be updated without reloading the entire webpage.

The demoJS code of Ajax is as follows:
<Span style = "font-size: 18px;"> <script type = "text/javascript"> // Step 1: Create the xmlHttp object var xmlHttp = createXmlHttp (); function createXmlHttp () {var request; if (typeof (XMLHttpRequest) = "undefined") {// request = new ActiveXObject ("Microsoft. XMLHTTP ");} else {// request = new XMLHttpRequest ();} return request;} function ajax () {// Step 2: open (true, indicating asynchronous) xmlHttp. open ("GET"," Jax. aspx? Haha = "+ document. getElementById ("first "). value, true); // Step 3: Obtain the queried value xmlHttp. onreadystatechange = function () {// 4 indicates that the xmlHttp interaction is complete, and the status code returned by the 200 interaction with the background indicates that the normal interaction is complete, and 404 indicates that the file is not found. 500 indicates an internal server error. if (xmlHttp. readyState = 4 & xmlHttp. status = 200) {document. getElementById ("second "). value = xmlHttp. responseText; }}// Step 4: Send xmlHttp. send () ;}</script> </span>
HTML code
<span style="font-size:18px;"><body>    <input type="text" id="first" onkeyup="ajax()" />    <input type="text" id="second"  /></body></span>
Server code
<Span style = "font-size: 18px;"> using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; namespace library management System demo {public partial class ajax: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {// string. isNullOrEmpty ("string") to determine whether the string is null or empty. if it is Null or null, true if (! String. isNullOrEmpty (Request. queryString ["haha"]) {Response. write (Request. queryString ["haha"]); // output the content to be output. end (); // prompt output, otherwise the entire html will be output }}</span>
It is not easy to compile regular Ajax code using JQuery Ajax, because different browsers have different Ajax implementations. This means that additional code must be written to test the browser. However, the JQuery team solved this problem for us. We only need a line of simple code to implement Ajax.
Demojs code of JQuery Ajax
<Span style = "font-size: 18px;"> HTML code
<span style="font-size:18px;"><body>    <input type="text" id="first"  />    <input type="text" id="second" onkeyup="jqueryAjax()" /></body></span>
Server code
<Span style = "font-size: 18px;"> using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; namespace library management System demo {public partial class ajax: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {if (! String. isNullOrEmpty (Request. queryString ["soso"]) {Response. write (Request. form ["chuandi"]); Response. end () ;}}}</span>

Conclusion: The application is still limited, and there are still many deficiencies in theoretical knowledge. You still need to keep learning. Many examples are provided when learning this knowledge. There is a website to do very good, there are a lot of examples, here recommended: http://www.w3school.com.cn/

 

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.