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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:02:05+00:00 2026-05-28T05:02:05+00:00

Im trying to get a page talking to a webservice through jquery. this is

  • 0

Im trying to get a page talking to a webservice through jquery.

this is the jquery:

function Test(item) {
  $.ajax({
    type: "POST",
    url: "WebService.asmx/test",
    data: '{' +
                    'Item:"' + item + '"' +
               '}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        var data = jQuery.parseJSON(msg);
        if (!data.error) {
            alert("YES!!");
        }
        else {
            alert("Error" + " " + data.error);
        }
    },
    error: function (msg) {
        alert('Get Details Failure: ' + msg);
    }
 });
};

This is the web service:

    using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Web.Script.Services;
using System.Web.Script.Serialization;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService : System.Web.Services.WebService {

    public WebService () {}

    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public string Test(string Item)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();
        string strJSON = js.Serialize(Item);
        return strJSON;
    }
    }

but i get his error:

System.InvalidOperationException: Request format is invalid: application/json; charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

why???

  • 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-28T05:02:06+00:00Added an answer on May 28, 2026 at 5:02 am
     data: '{' +
                        'Item:"' + item + '"' +
                   '}',
    

    needs to be:

    data: JSON.stringify({Item: item}),
    

    that will produce:

    '{"Item": "item's value"}'
    

    That is valid json. You were missing the " around Item


    In addition:

    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public string Test(string Item)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();
        string strJSON = js.Serialize(Item);
        return strJSON;
    }
    

    should be:

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string Test(string Item)
    {
        return Item;
    }
    

    You don’t need to serialize that string.

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

Sidebar

Related Questions

I'm trying to get an HttpRequest to post this URL https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&USERNAME=yo@yo.com&PASSWORD=What!What ! I've tried
I am trying to get simple jQuery to execute on my Content page with
I am really suffering here trying to get this ajax call to work, sorry
I'm trying to get an html page to display an XML file formatted with
iam trying to get all object's xpath's from loaded page via selenium something similar
I'm trying to get my FBML canvas page to automatically prompt new app users
I am trying to get the Y scroll index for a web page in
I'm trying to get meta tag information for each page on a particular site,
I'm trying to get the .Left property of a specific tab page in a
I have a problem with a page where I am trying to get colorbox

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.