Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6660575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:10:21+00:00 2026-05-26T02:10:21+00:00

I have created a code like this to access method AddNums in my webservice.

  • 0

I have created a code like this to access method AddNums in my webservice. I am sending data through webservice to get output. but it is not giving any 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. I have tested webservice with inbuilt client in Visual Studio, it is 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);
    }

     }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:10:22+00:00Added an answer on May 26, 2026 at 2:10 am

    This is wrong way

    data: "{2,3}",
    

    Right Way is

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

    for passing the parameter to external file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created this code, and when I run it, don't get any errors
I have a framework with objects and data access code. This objects are mapped
I'm using PHP5 to create XML files. I have code like this: $doc =
I have created a report in MS Access report and write some VBA code
I have created a data access layer in my web app which uses ObjectDataSource
Say I have code in my main mxml and in a function like this:
Suppose I have a table like: create table { id numeric(5,3), code varchar(10) }
I like Doxygen to create documentation of C or PHP code. I have an
I have created an iframe code that I want people to use as a
I have created some python code which creates an object in a loop, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.