Home > Web Front-end > JS Tutorial > JavaScript calls background methods

JavaScript calls background methods

醉折花枝作酒筹
Release: 2023-01-05 16:07:29
Original
3055 people have browsed it

In javascript, you can use "<%=%>" to call the background, and the syntax is "<%=method>". Javascript calls a server-side exe or a function in a dll, or even a Linux binary executable file, runs it on the server, and returns the result to js after running.

JavaScript calls background methods

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.

javascript calls the background method

##Directly use <%=%>call

Front-end JS:

<script type="text/javascript">  
       var methodStr = "<%=BehindMethod() %>";  
       alert(methodStr);  
       </script>
Copy after login

Backend method:

public static string BehindMethod()
        {
            return "这是一个后台的方法";
        }
Copy after login

1)

BehindMethod()publicAccess modification before the method Don’t forget the symbol;

2) This method has limitations - BehindMethod() will only be automatically called when the

ASPX page is loaded or posted back, and the call cannot be controlled manually.

Recommended learning:

javascript video tutorial

The above is the detailed content of JavaScript calls background methods. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template