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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:23:10+00:00 2026-06-09T07:23:10+00:00

I use ajax in my applicataion, and I have to use the $.post method.

  • 0

I use ajax in my applicataion, and I have to use the $.post method.

Normally, the data sent to server are key-value paires. I can get them through:

HttpContext.Current.Request.QueryPara['name'];
....

But in some cases, the data to be sent to the server does not contain the name.

It is just a xml segments.

Like this:

var data='<data>xxxxx<data>';
$.post('http://server/service.asmx/test',data,function(){
  //callback
},'xml');

Then How can I get the data in my webmethod?

  • 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-06-09T07:23:12+00:00Added an answer on June 9, 2026 at 7:23 am

    You should have to use ‘json’ dataType to pass data to the web-method.

    Have a look at sample:

    Service.asmx


    [ScriptService]
    [WebService(Namespace = "http://localhost/testapp/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Service : System.Web.Services.WebService{
       [WebMethod]
       public int Square(int no){ return no * no;}
    }
    

    and JavaScript code to request this webmethod

    <script type="text/javascript">
    $(function () {
        $("#button1").click(function () {
            $.ajax({
                type: "post",
                url: "service.asmx/Square",
                data: "{no: 10}",
                dataType: "json",
                contentType: "application/json",
                success: function (data) {
                    alert("Result :" + data.d);
                },
                error: function (src,type,msg) {
                    alert(msg); //open JavaScript console for detailed exception cause
                }
            });
        });
    });
    </script>
    
    <body>
      <input type="button" id="button1" value="Square" />
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do i use ajax to send POST requests to the server instead of
EDITED I'm trying to use jquery/ajax to display data returned from a django method.
I'm writing a small ajax class for personal use. In the class, I have
I have a button that uses jQuery and ajax to call a server side
At the moment I'm using the post method like this $.ajax({ type: POST, url:
I have a jquery Ajax call function that I use to submit form to
i have a webmethod that call it by jquery ajax .in web method i
I have an OperationContract method where I am trying to query and insert data
I have Spring MVC web-application. I want to use Hibernate and AJAX. There are
I have a MVC application where i call a jquery post method on textbox

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.