jquery - Web service call with ajax in asp.net -
i trying use web service using jquery ajax. webservice method called , parameter passed well, wonder why ajax not execute success function
here's ajax call
<script type="text/javascript"> function btn_add() { var = $("#tb_a").val(); var b = $("#tb_b").val(); var c = $("#tb_c").val(); var para = "a=" + + "&b=" + b + "&c=" + c; $.ajax({ type: "post", url: "mywebservice.asmx/add", data: para, datatype: "text", success: function (res) { alert("success"); console.log(res); } }); } </script>
edit
here webservice code
[system.web.script.services.scriptservice] public class mywebservice : system.web.services.webservice { [webmethod, scriptmethod] public int add( int a, int b, int c) { return + b + c; } }
you should take @ documentation, says call like this:
$.ajax({ type: "post", url: "mywebservice.asmx/add", data: { : $("#tb_a").val(), b : $("#tb_b").val(), c : $("#tb_c").val() }, success: function (res) { alert("success"); console.log(res); } });
if in server have this:
public string myfunction(string a, string b, string c) { return + b + c; }
now, if doesn't work, take @ answer, it's different way accomplish want
Comments
Post a Comment