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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:50:25+00:00 2026-05-28T02:50:25+00:00

Here’s some javascript: $.ajax({ type: POST, url: default.aspx/GetDate, contentType: application/json; charset=utf-8, data: {}, dataType:

  • 0

Here’s some javascript:

$.ajax({
        type: "POST",
        url: "default.aspx/GetDate",
        contentType: "application/json; charset=utf-8",
        data: {},
        dataType: "json",
        success: function(result) {
            alert(result.d);
        }
     });

The above method works as I would expect and alerts the string returned from the [WebMethod] called GetDate in default.aspx

But when I use:

$.post(
        "default.aspx/GetDate",
        {},
        function(result) {
            alert(result.d);
        },
        "json"
     );

The alert in this success method never fires.

In firebug I can see that the POST has basically worked – it returns 200 OK
But the response in this case is the HTML of the entire default.aspx page rather than the JSON returned when I use the $.ajax() method.

EDIT:
The response and request headers shown in firebug are NOT identical.

With $.ajax()…

REQUEST:
Accept  application/json, text/javascript, */*; q=0.01
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding gzip, deflate
Accept-Language en-gb,en;q=0.5
Connection  keep-alive
Content-Type    application/json; charset=utf-8
Cookie  (removed)
Host    (removed)
Referer (removed)
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
X-Requested-With    XMLHttpRequest

RESPONSE:
Cache-Control   private, max-age=0
Content-Length  27
Content-Type    application/json; charset=utf-8
Date    Wed, 11 Jan 2012 12:36:56 GMT
Server  Microsoft-IIS/7.5
X-Powered-By    ASP.NET

With $.post()…

REQUEST:
Accept  application/json, text/javascript, */*; q=0.01
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding gzip, deflate
Accept-Language en-gb,en;q=0.5
Connection  keep-alive
Cookie  (removed)
Host    (removed)
Referer (removed)
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
X-Requested-With    XMLHttpRequest

RESPONSE:
Cache-Control   private
Content-Length  13815
Content-Type    text/html; charset=utf-8
Date    Wed, 11 Jan 2012 12:36:53 GMT
Server  Microsoft-IIS/7.5
X-AspNet-Version    2.0.50727
X-Powered-By    ASP.NET

Can I use the the $.post() method for this, or do I have to use the $.ajax() method?

  • 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-28T02:50:26+00:00Added an answer on May 28, 2026 at 2:50 am

    That’s normal. When you use $.post you cannot set contentType: 'application/json' as you do with $.ajax. And the server expects this header. So basically you cannot invoke an ASP.NET page method with $.post.

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

Sidebar

Related Questions

here is the scenario 1: user starts to type some word, autocomplete engine shows
Here is my problem : I have a post controller with the action create.
Here's some of my production code (I had to force line breaks): task =
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
Here is my javascript code for a cursor focus function to go to username
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY
Here is an example: I have a file 1.js, which has some functions. I
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs

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.