1. In the Web. config file, add the following settings
<add verb= "Post,get" path= "*.ashx" type= "ajaxpro.ajaxhandlerfactory,ajaxpro.2"/>
2. Add a page with a page name of defalut.aspx
Write the following code in the background Defalut.aspx.cs page:
protected void Page_Load (object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax (typeof (Defalut));
}
[Ajaxpro.ajaxmethod]
public string GetResult (string name)
{
if (name== "Zhang San")
return "OK";
Else
return "NO";
}
3. Front-end JS calls the method of the background, the code is as follows:
function GetValue () {
var value=defalut.getresult ("John Doe"). Value;
alert (value);
}
The value obtained is no, because name is John Doe, not Zhang San, according to the background of the judgment, so the value obtained is No.
General This method is so application, we practice it! This is very useful oh!