ajax - webserivce is called from my jquery -


i have created code access method addnums in webservice. sending data through webservice output. not giving output.

   <html xmlns="http://www.w3.org/1999/xhtml">    <script src="scripts/jquery%20v1.6.4.js" type="text/javascript"></script>     <script type="text/javascript">     $(document).ready(function () {     $("#btn").click(function () {         alert('i have been clicked');         $.ajax({             type: "post",             url: "http://localhost:5554/service1.svc",             data: "{2,3}",             contenttype: "application/json; charset=utf-8",             datatype: "json",             success: function (msg) {                 $("#output").text(msg.d);             }         });      });     });      </script>     <head runat="server">     <title></title>      </head>      <body>      <form id="form1" runat="server">        <input type="button" id="btn" value="click me" /> <br /> <br />         <span id="output"></span>         </form>       </body>        </html> 

implementation of webserivce. have tested webservice inbuilt client in visual studio, working perfectly.

  namespace wcfservicetest   {      [system.web.script.services.scriptservice]    public class service1 : iservice1    {     public string getdata(int value)     {         return string.format("you entered: {0}", value);     }      public compositetype getdatausingdatacontract(compositetype composite)     {         if (composite == null)         {             throw new argumentnullexception("composite");         }         if (composite.boolvalue)         {             composite.stringvalue += "suffix";         }         return composite;     }     [system.web.services.webmethod(bufferresponse = false)]     public int addnums(int val1, int val2)     {         return (val1 + val2);     }       }     } 

this wrong way

data: "{2,3}", 

right way

data: {para1:value1,para2:value2}, 

for passing parameter external file.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -