Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to call background methods by ajax

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to call the background method of ajax, the article introduces in great detail, has a certain reference value, interested friends must read it!

There are three methods I have used:

1 add a hidden button to the page, define the event, and then execute the $("# hide btnID"). Click () of js to execute the background method

2 use ajaxPro to execute

3 execute with the url: page address / (static) method name of ajax

In this method, the method must be static, so for example, on the page _ default, the example is as follows

The copy code is as follows:

Public partial class _ Default: System.Web.UI.Page

{

Static int sVar = 1

Int abc = 3

Int result

[WebMethod]

Public static string AjaxGetMethod ()

{

SVar = 2; / / static variables can be called directly

_ Default d = new _ Default (); / / result,abc cannot be used if it is not instantiated

NoStaticFun nsf = new NoStaticFun (); / / test cannot be used without instantiation

D.result = nsf.test ()

D.result = d.abc

Return d.result

}

}

Public class NoStaticFun

{

Public int test ()

{

Return 2

}

}

In this example, I've marked it, and I'd like to discuss with you what other better methods are, or how you apply them.

The above is all the contents of the article "how to call background methods in ajax". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report