Recently received a reverse telecommuting, is to add some features on the original ASP. NET architecture, using jquery is 1.6.2 version, nonsense not much to say, directly on the code
Front Code
$.ajax ({type:"POST", URL:"Myphotolist.aspx/btnselectclick", ContentType:"Application/json", Data:"{‘Photoname': ' "+ currentphotoname +" ', 'Buttonval': ' "+currentbuttonval+" '} ", //dataType: "JSON",Successfunction(e) {alert (Success); }, Error:function(e) {alert ("Failed"); } });
The above is a normal jquery Ajax method, look at the background code
[WebMethod] void btncomment (String photoname, String commentstr) { return ; }
The background method must add [WebMethod], in jquery two red places, respectively, corresponding to the background method of two parameters, the name can not be changed
However, in my system how also can not execute success, in the internet also found a lot of solutions are not, finally consulted my master, the problem solved
Because it is an old system, it is using. NET 2.0, which later changed to 3.5 or later issues solved
Click on Project, select Property page, select Production tab, Target framework changed to 3.5