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 3494284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:59:15+00:00 2026-05-18T11:59:15+00:00

I would like to pass parameters to my webservice from jquerys ajax. How can

  • 0

I would like to pass parameters to my webservice from jquerys ajax. How can I do that?

I’ve already looked through a few of the related questions but couldn’t find a solution that worked for me. I’ve tried this: jQuery AJAX parameter not being passed to MVC but I’m not using mvc so I’m sure that is why the solution isn’t working.
My jquery looks like this:

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "CarService.svc/GetCar",
                data: {CarID:117},
                dataType: "json",
                success: function (data) {
                    $("#lblCurrentTime").text("");
                    $("#lblCurrentTime").text(data.d.CarID);
                }
            });

Something is wrong with my ‘data’ part, correct? If leave the data: part as data: “{}” I can get my method to run (and I don’t pass any parameter) but the moment I try the above out firebug tells me:

Firebug's log limit has been reached. 0 entries not shown.  Preferences  
POST http://localhost:64461/TimeService.svc/GetCar
POST http://localhost:64461/TimeService.svc/GetCar

500 Internal Server Error
  1.12s

My Webservice looks like this:

[OperationContract]
    public CarTable GetCar(int id)
    {
        using (var sqlc = new SqlConnection(@"sdfgsdfg"))
        {
            sqlc.Open();
            var cmd = sqlc.CreateCommand();
            cmd.CommandText = "HUGE QUERY HERE ^^";
            //id = 117;
            cmd.Parameters.Add("CarID", System.Data.SqlDbType.Int).Value = id;
            using (var reader = cmd.ExecuteReader())
            {
                CarTable Cars = new CarTable();

                while (reader.Read())
                {
                    Cars.CarID = reader["CarID"].ToString();
                    Cars.CarName = reader["CarName"].ToString();
                }


                return Cars;

            }
        }
    }
[DataContract]
public class CarTable
{
    [DataMember]
    public string CarID { get; set; }
    [DataMember]
    public string CarName { get; set; }
}

EDIT: If I change the data part to:

data: CarID=117,

I get Sys.ParameterCountException: Parameter count mismatch.
[Break On This Error] {name: “format”, type: String}

  • 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-18T11:59:16+00:00Added an answer on May 18, 2026 at 11:59 am

    First you should verify that you include attribute

    [WebInvoke (ResponseFormat = WebMessageFormat.Json)]
    

    to the GetCar method or do the same in web.config.

    Second you should use data:"117" or data:JSON.stringify(117) instead of data: {feat:117}.

    UPDATED: If you would has a more complex data input, for example as an object CarTable the data parameter should be data:JSON.stringify({CarID: 117, CarName: "BMW"}), so it should be built in the same way. The JSON.stringify is defined in http://www.json.org/js.html.

    One more remark. After the successful return of data you will see that the data returned back should be accessed not with data.d.CarID, but with data.CarID instead. ASMX web-service place the data in the property d, but not WCF service.

    UPDATED 2: I don’t know which small error you do, so I created a small WCF service which do what you need. You can download the source code here http://www.ok-soft-gmbh.com/jQuery/WcfData.zip. To be sure that you will be able compile it I used Visual Studio 2008. In Visual Studio 2010 the web.config file can be much more simple.

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

Sidebar

Related Questions

I would like to know whether it is possible to pass parameters from a
I would like to pass multiple parameters from the iphone sdk to a server-side
I would like to pass data from a database column to another page via
I would like to pass values into the constructor on the class that implements
I have a form that has label values that I would like to pass
I would like to to pass the colors for the events through my json
I hava a perl subroutine where i would like to pass parameters as a
I've implemented a MXML custom components and I would like to pass parameters to
i would like to pass multiple parameters in my callback function and don't know
Gzip can take parameters, as described here . I would like to gzip some

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.