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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:38:12+00:00 2026-05-28T03:38:12+00:00

I have a C# ASP.NET web service running (successfully) on this PC. I can

  • 0

I have a C# ASP.NET web service running (successfully) on this PC. I can test the LogonUser method via IIS and also call it from a test console application.

I have a second project, an HTML page that calls the web service using jQuery. This always fails and so quickly I don’t think it’s actually communicating with the service, making me think there’s a syntax error in the JavaScript.

Have I got things configured correctly?

C# Web method:

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

    [WebMethod]
    public string LogonUser(string _usercode, string _password) {
        ...             
    }
}

HTML source:

<body>
<form id="logon" action="">
<h1>
    Time Recording Logon</h1>
<p>
    <label>Usercode</label>
    <input id="usercode" type="text" />
</p>
<p>
    <label>Password</label>
    <input id="password" type="password" />
</p>
<p>
    <a type="submit" class="submit" id="LogonUser">Logon</a>
</p>
</form>
<!--Browsers block while requesting, loading, and executing JavaScript, defer this until as late as possible.-->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("a#LogonUser").click(function (e) {
            e.preventDefault();
            $.ajax({
                type: 'POST',
                url: 'http://143.96.130.156/TimeRecording/TimeRecordingService.asmx/LogonUser',
                data: '{"_userCode": "' + $("input#usercode").val() + ", '_password': " + $("input#password").val() + '"}',
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: OnSuccess,
                error: OnError
            });
            function OnSuccess(data, status) {
                alert(status);
            }
            function OnError(request, status, error) {
                alert(status);
            }
        });
    });    
</script>

This is always returning an error immediately when I click the Logon button.

Can you see or think why?

Thank you,
Aaron.

  • 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-28T03:38:12+00:00Added an answer on May 28, 2026 at 3:38 am

    this is because of the Same origin policy. you cannot use ajax to call external sites. if you really want to use, you have to use JSONP. Or you can use serverside proxy for this. means, call external site in the server side and do ajax call to the that webservice.

    see my answer here

    for more detail on how to call C# inside JavaScript see following links,

    http://cmsnsoftware.blogspot.com/2010/11/simple-ajax-request.html

    http://cmsnsoftware.blogspot.com/2011/01/how-to-call-csharp-function-in-ajax.html

    http://cmsnsoftware.blogspot.com/2011/02/how-to-use-ajax-auto-complete-in-aspnet.html

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

Sidebar

Related Questions

I have an ASP.NET web service that I can access via a windows program
I have an IIS with ASP.Net web service running, I need to upgrade it
I have an ASP.NET web service running that accepts both HTTP POST and SOAP
I have an irritating problem, I'm creating an asp.net web service; this service should
I have written an ASP.NET web service. It looks like this: WebServices.logic pLogic =
I have a asp.net 2.0 web site with WCF service hosted inside it running
This is my first test for Asp.Net Web Application. We have an Engine consisting
I have an ASP.Net web application running on an IIS server, and I need
I have an ASP.NET web service which does some heavy lifting, like say,some file
i have an ASP.NET web service that returning a custom entity object (Staff): [WebMethod]

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.