Home >Web Front-end >JS Tutorial >How to implement Ajax to call the server asynchronously

How to implement Ajax to call the server asynchronously

php中世界最好的语言
php中世界最好的语言Original
2018-04-14 10:05:291266browse

This time I will show you how Ajax implements asynchronous call to the server. What are the precautions for Ajax to implement asynchronous call to the server. The following is a practical case, let's take a look.

How to use ajax, call the same way in the cs file in js, the steps are as follows

(1) Download ajax.dll and add the reference of the project.

(2) In the node of the project's webconfig, add Node

(3) Add Ajax.Utility.RegisterTypeForAjax(typeof(ClassName)); in the pageload method of the aspx page; the ClassName here is the class name of the current cs file.

(4) Next, all methods written in cs that you want to call in js must be preceded by [Ajax.AjaxMethod()]. If you want to call session, then you must write: [Ajax.AjaxMethod(HttpSessionStateRequirement.Read)].

(5) In the js method, write var address = ClassName.MethodName('parameter').value; //ClassName is the class name, MethodName is the method name, and the passed-in parameter is parameter.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to download json format array to excel table with JS

How to operate jackson to parse json characters Case conversion of the first letter in a string

The above is the detailed content of How to implement Ajax to call the server asynchronously. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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