An example on how to use jquery and Ajax. net Professional together

Source: Internet
Author: User
Get started with the ajaxpro code

Ajax. net Professional (ajaxpro) is a Ajax framework for the Microsoft. net Framework which you can use with any. NET language like C #, VB. net, J # To create javascript proxies to invoke any. net method from the client-side. download the ajaxpro.2.dll (. NET 2.0) from http://www.ajaxpro.info/, add the reference and setup the web. config:

 
<Configuration> <Location Path = "ajaxpro"> <system. web>  

Next we need to write our. net method that will return the data we will ask. A simple static method can be used with nearly any. NET data type, but I recommend to use only structs/classes with JavaScript similar data types for the properties.

 
Namespace mynamespace {public class myclass {[ajaxpro. ajaxmethod] public static string helloworld (string s) {return "hello" + S ;}}}
[Edit]

The Ajax endpoint

To get the name of the Ajax request endpoint you must use the namespace, classname and the Assembly name like below:

 
String Path = "/ajaxpro/mynamespace. myclass, "; Path + = typeof (myclass ). assembly. fullname. split (',') [0]; Path + = ". ashx ";

Write the above string to a javascript variable using registerhiddenfield or any other way.

[Edit]

Run the ajaxpro request

The next step wocould be to use jquery to invoke the ajaxpro request. I used a very simple example to show what you need.

 
$. Ajax ({type: "Post", URL: myajaxpath, // This is the path from above data: '{"S": "Hans"}', beforesend: function (xhr) {xhr. setRequestHeader ("X-ajaxpro-method", "helloworld") ;}, success: function (s) {var o = NULL; eval ("O =" + S + "*" + "/"); alert (o );}});
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.