I wrote an article
A simple Ajax solution in ASP. NET
I recently updated him and made a more detailed demo.
- Blqw. Json is added, so more types of parameters and return values are supported.
- Optimized exception Handling
- Pager object added
- Optimized the method of registering page variables, making it safer
Features
First, he does not need any configuration files.
No additional dll, he is open source, as long as you want, he only has 2 cs files
User = message = ["name:" + user. name, "Age:" + user. age, "birthday:" + user. birthday]. join ("\ n \ r"
Text1.value = "retrieving data..." a = "server return:" + 0 );
User = message = ["name:" + user. name, "Age:" + user. age, "birthday:" + user. birthday]. join ("\ n \ r" "exception:" +
Running Mode
First, add it to Page_Load or <% ...... %> on the front-end page.
Ajax2.Register();
In this method, determine the parameters of the current page. If a common request is made, register the js Code to the page.
Complete js registration in debug mode
Javascript full debug javascript =Complete Js
Register simplified js in release Mode
Javascript min! Debug javascript =Simplified js
Next, the method marked as AjaxMethod will be reflected and then added to the js of the page, for example
PostAjax1(){ blqw.Ajax.Exec('PostAjax1',arguments);}
Then you can directly use PostAjax1 () in js to call the background method.
The blqw. Ajax. Exec () method will use ajax to request the current page and add the post parameter, for example
Blqw. ajaxdata: {Name: "Bing Lin qingwu", Age: "28", Birthday: "1986-10-29"
At this time, the blqw. Ajax2.Register method will be entered, and the blqw. ajaxmethod will be judged. If this parameter exists, the Literacy component will be used to reflect the corresponding method, and the json component will be used to deserialize the parameter,
Call the background method and serialize the parameters and output them to the page.
If an Exception occurs in the background method call, the Exception object (Exception) will be serialized to the foreground, and throw out in js
Page Demo
Download
Blq1_ajax2demo.rar
Https://code.csdn.net/jy02305022/blqw-ajax2