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/