Get the App
SLTechnology News&Howtos  ›  Development  › 

How to call background methods by ajax

Shulou Source: shulou.com Published: 2022-06-03 06:09:16 10月20日 Update

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!

Tags: Method background static page code content example example article next event value interest variable name address buddy partner more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info Shulou Information Xiaomi Linux