ASP. net ajax series (II)
In the last Ajax operation, we used the native ASP. NET control, but it has many drawbacks and is inefficient. In addition, there is a file upload BUG: http://blog.csdn.net/zhaoqiliang527/article/details/4457961 . So we seek a better implementation method. jQuery's Ajax method works with the general ashx processing program. The advantage of jQuery is its strong compatibility (there is a team dedicated to development behind it). It is easy to use (I learned how to find an API in just a few minutes) and has powerful functions (encapsulated native js, you can call a method to implement many functions ). Generally, the Ashx processing program is MS's own. It can be seen from its name that it is used to handle something (forgive me for being easy to learn ), in addition, it does not reconstruct the lifecycle of the entire page during execution, which avoids the overhead problem caused by Control tree generation. Now let's talk about how the two can be combined to implement ajax. First, we should build a page: copy the Code <% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "ashxAjax. aspx. cs "Inherits =" WebApplication1.ashxAjax "%> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> jQuery Ajax </title> <script type =" text/javascript "src =" JavaScript/jquery-11.js "> </script> <script type = "text/javascript"> $ (function () {$ ("# txtId "). blur (function () {var a =$ ("# txtId "). val (); $. ajax ({type: "post", url: "Handler1.ashx", data: {m: a}, success: function (result) {var res = result. toString (); $ ("# lblShow" ).html (res) ;}}) ;}); </script>