Home  >  Article  >  Web Front-end  >  Example of front-end js calling background method_javascript skills

Example of front-end js calling background method_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:11:111245browse
1. Background method
Copy code The code is as follows:

public string AA(string cc)

{

string dd = "Hello everyone is really good";

string message=dd cc;
return message;

}

Front-end JS
Copy code Code As follows:

function Init() {
var v = "China";
var s = '<%=AA("' v '") %>';
alert(s);
}

2. Post submission

PVISAjax.aspx is the processed page

The data in {} is the parameter

data is the returned data
Copy the code The code is as follows:

$.post("PVISAjax.aspx", { Method: "PLANT", PlantName: plantName }, function (data) {
if (data != null) {
list = new Array(); //Split characters
list = data.split(",");
var gfoN = list[0];
var grfoN = list[1];
var elN = list[2];
var ulN = list[3];
var etbaN = list[4];
gfo.SetValue(gfoN);
grfo.SetValue(grfoN);
exeuro.SetValue(elN);
exusd.SetValue(ulN);
etba.SetValue(etbaN);
pvisName.SetValue(etbaN);
etba.mainElement.title = etbaN;
}
});

Backend

Convert.ToString(Request["PlantName"]);Receive the passed parameters
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