JS Ajax foreground How to give the background class function pass parameter _ajax correlation

Source: Internet
Author: User

The normal page method is advertised as WebMethod and is accessed in JavaScript form.

1 method to public static decoration, the return type is best string.
2 method before adding the [WebMethod] attribute.
3 client-side Access uses the Post method to interact with JSON as the data form. Otherwise, the entire page of HTML is returned.
4 in jquery access, the DATA.D in the callback is the true return of the content.
5 Access URL is: http://abc.com/abc.aspx/GetTime if there is a GetTime public static method.


public static string GetTime ()
DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss");

Script (called in jquery)

$.ajax ({
Url:url, method
: "Post",
DataType: "JSON",
contentType: "Application/json; Charset=utf-8 ",
success:function (data) {
$ (" #id "). HTML (DATA.D);/See 3rd
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.