Jquery can directly call the PAGE method, but every time it is used, it is always a wave of twists and turns. The following are the precautions during use.
1. In vs2008, it seems that the page background page cannot be called directly. It is said that the configuration file must be modified.
2. To call the page background method, you must first reference the namespace using system. Web. Services. Then the method must be a static method, and the method must be marked as [webmethod].
3. jquery calls at the front end as follows:
$. Ajax ({
Type: "Post ",
Contenttype: "application/JSON ",
URL: "/admin/sysmanage/adminmenuadd. aspx/addadminmenu ",
Data: "{menuname: '" + menuname + "', parentmenu: '" + parentmenu + "', menupath: '" + menupath + "', sortnum: '"+ sortnum +"', status: '"+ status + "'}",
Datatype: 'json ',
Success: Function (E ){
Alert (E. D );
}
})
There are several important parameter types:
1. unlike jquery's call to ashx, the parameter data must be written in double quotation marks, for example, data: "{parm1: '" + parmvalue + "'}". Data: {parm1: parmvalue}
2.Contenttype: "application/JSON ",Type must be specified for this item
3. Why does alert write like this? "E. D"
The returned result is of the JSON type. The format is {"D": 1}
You can see in httpwatch