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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:01:35+00:00 2026-05-20T00:01:35+00:00

I’ve created a windows service that runs locally and provides a web service which

  • 0

I’ve created a windows service that runs locally and provides a web service which can be communicated with via ajax calls. I’m trying to write some code to detect if the web service is running on localhost so I can prompt users to install the application if it isn’t running. When the service isn’t running, the .ajax call isn’t triggering the error callback, even after a timeout elapses. Here is the code I’m running right now

$.ajax({ url: 'http://localhost:12345/GetVersion/',
        dataType: 'json',
        timeout: 1000,
        complete: function() {
            alert('complete');
        },
        success: function() {
            alert('success');
        },
        error: function() {
            alert('error');
        }
    });

When the service is running, both complete and success are called. When the service is stopped I never get the complete or error alert.

Any ideas why the callback is never getting triggered? Are there any other ways to see if the service is running then by simply calling one of the methods?


UPDATE:
Fiddler doesn’t report anything on localhost or 127.0.0.1 requests, so I created a subdomain for our domain that points to 127.0.0.1. When the service is running, the subdomain works as expected, when the service is not running, fiddler gives me this error:

[Fiddler] Connection to localhost.stayhealthy.com failed.Exception 
Text: No connection could be made because the target machine actively refused it 127.0.0.1:49994

I still get the same results on the website making the call though. The error callback is never triggered.


UPDATE 2:
This is a complete working example you should be able to test with.

<html>
<head>
    <title>Ajax Localhost Test</title>
    <script language="javascript" type="text/javascript" src="jquery-1.4.2.js"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function(){
            $('#messages').append("Starting<br />");

            $.ajax({ url: 'http://localhost:12345/GetSomething/?callback=?',
            dataType: 'json',
            timeout: 1000,
            complete: function() {
                $('#messages').append("Complete<br />");
            },
            success: function(version) {
                $('#messages').append("Success<br />");
            },
            error: function(request, status, error) {
                $('#messages').append("Error<br />");
            }
        });
        });
    </script>
</head>
<body>
    <h1>Ajax Localhost Test</h1>
    <div id="messages"></div>
</body>
</html>

Unless you have a service running on localhost:12345 the call should fail, but never trigger error or complete.

  • 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-20T00:01:35+00:00Added an answer on May 20, 2026 at 12:01 am

    This has been fixed in jquery 1.5. The script in the original post works as expected now and I can get rid of the timer workaround.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

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.