The ultimate solution to the problem that the server or virtual host does not support AjaxPro
- 2020-05-17 05:06:00
- OfStack
Method: add a mapping of a.ashx file in the website properties -- home directory -- configuration --
The mapped file path is: C:\WINDOWS\ Microsoft.NET \Framework\ v2.0.50727 \ aspnet_isapi.dll extension:
ashx action: GET, HEAD POST, DEBUG
Check to see if the file exists
The first thing to do is in Web.config < system.web > To add the following
< httpHandlers >
< add verb="POST,GET" path="AjaxPro/*.ashx" type="AjaxPro.AjaxHandlerFactory, axPro" / >
Or (see version)
< add verb="POST,GET" path="ajaxpro/*.ashx" pe="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/ >
< /httpHandlers >
Then add the following line of code to Page_Load on the server side
AjaxPro.Utility.RegisterTypeForAjax(typeof(index));
Let's implement how to invoke server-side methods on the client side using javascript
Server-side method that returns 1 DataSet
This method is then called on the client side
The mapped file path is: C:\WINDOWS\ Microsoft.NET \Framework\ v2.0.50727 \ aspnet_isapi.dll extension:
ashx action: GET, HEAD POST, DEBUG
Check to see if the file exists
The first thing to do is in Web.config < system.web > To add the following
< httpHandlers >
< add verb="POST,GET" path="AjaxPro/*.ashx" type="AjaxPro.AjaxHandlerFactory, axPro" / >
Or (see version)
< add verb="POST,GET" path="ajaxpro/*.ashx" pe="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/ >
< /httpHandlers >
Then add the following line of code to Page_Load on the server side
AjaxPro.Utility.RegisterTypeForAjax(typeof(index));
Let's implement how to invoke server-side methods on the client side using javascript
Server-side method that returns 1 DataSet
[AjaxPro.AjaxMethod]
public DataSet Change()
{
string str="select xjh,xm from xs_jbxx";
ds=cla.Bind(str);
return ds;
}
This method is then called on the client side
<script language="javascript">
function Change()
{
WebServer.index.Change(change_callback)
}
function change_callback(response)
{
var ds=response.value;
var content=document.getElementById("newDG");
var table=null;
for(var i=0;i<ds.Tables[0].Rows.length;i++)
{
if(i==0)
{
table=ds.Tables[0].Rows[i].xm+"<br>";
}
else
{
table+=ds.Tables[0].Rows[i].xm+"<br>";
}
}
content.innerHTML=table;
}
</script>