Making Ajax simpler

Source: Internet
Author: User

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

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.