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

  • Home
  • SEARCH
  • 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 8884643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:06:37+00:00 2026-06-14T21:06:37+00:00

I am trying to make an AJAX call using jQuery to a C# Web

  • 0

I am trying to make an AJAX call using jQuery to a C# Web Service located under the same website. No matter what I find/try, I keep on receiving a 500 error as such:

Request format is unrecognized for URL unexpectedly ending in '/MyTest'.

jQuery AJAX call from web page

    $.ajax({
        type: "POST",
        url: 'http://172.1.1.10/MYService/MyService.asmx/MyTest',
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            alert(data);
        },
        error: function (data, errorThrown) {
            alert("Fail");
            alert(errorThrown);
        }
    });

Web Service (MyService.asmx) Code Behind

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string MyTest()
{
    return "Hello World";
}

and yes I have the following uncommented at the top:

[System.Web.Script.Services.ScriptService]

When I try to load my web page, I get the alert window saying “Fail”. This is when I receive the 500 error (see top of post).

Too many people suggested adding this to the web service’s web.config:

Web Service (Web.config)

<configuration>
  <system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>
  </system.web>
 </configuration>

Upon adding this, I can hit the local machine with this address:

http://172.1.1.10/MYService/MyService.asmx/MyTest

and I get the proper response of “Hello World”. Prior to adding this I would get the same 500 Error message locally.

Both the web service and web site are setup on the same IIS instance, each as its own application, under the same web site in IIS. I know it is not a cross-domain issue because I am not getting the 503 error that you’d typically receive if this were true, nor am I getting the 404 error of File Not Found.

I’ve scoured the web and cannot seem to find a resolution to this.

  • 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-14T21:06:38+00:00Added an answer on June 14, 2026 at 9:06 pm

    Thanks to nick_w, using Chrome’s Console feature provided me with the following error:

    XMLHttpRequest cannot load http://172.1.1.10/MYService/MyService.asmx/MyTest. Origin http://mydomain.mysitename.com is not allowed by Access-Control-Allow-Origin.
    

    I discovered that when I was browsing to my site, I was using the domain name:

    http://mydomain.mysitename.com
    

    Whereas when I was calling the web service in code, I was using the IP Address:

    http://172.1.1.10
    

    Thus I technically was experiencing the cross-domain issue. Once I hit my site at the IP Address, or changed the webservice call to:

    http://mydomain.mysitename.com/MyService/MyService.asmx/MyTest
    

    Then it resolved just fine. I did need to update my code as such:

    $.ajax({
        type: "POST",
        url: 'http://mydaomin.mysitename.com/MYService/MyService.asmx/MyTest',
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            alert(data.d);
        },
        error: function (data, errorThrown) {
            alert("Fail");
            alert(errorThrown);
        }
    });
    

    Note, I added “.d” to the alert as it was returning an “Object object” rather then the result.

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

Sidebar

Related Questions

I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I'm trying to to make AJAX call with the jQuery library using the $.ajax()
I am trying to make an ajax call using jquery in my spring MVC
I am trying to make an Ajax call using JQuery to a servlet that
I am trying to make an ajax call using $.get() where I want to
i am trying to make a ajax call by making use of jquery UI
I am trying to make an ajax GET request to a WCF web service
I am trying to make two ajax requests in parallel using jQuery like this:
Am I missing something? I'm trying to do a simple ajax call using jquery
I am trying to make a MVC website with Ajax call. I have no

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.