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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:11+00:00 2026-06-10T00:55:11+00:00

My WCF REST service works fine, getJSON() and autocomplete() also work – BUT the

  • 0

My WCF REST service works fine, getJSON() and autocomplete() also work – BUT the result of the call to the WCF service is null unless I set a debug point in Firebug. If I don’t set a debug point the getJSON method will only return the JSON some of the time.

It seems that the getJSON method doesn’t wait for a response from my WCF service – which can take a second or two. Putting a debug point in my jQuery causes the script to “pause” while the WCF has time to return the JSON:

// Changing the selected item of the DropDownList will submit a different clientId
// to the WCF service. The result is used for the autocomplete()

$(document).ready(function () {
    var availableTags = "";
    $('#<%=ddlClients.ClientID %>').change(function () {
        var selectedClientId = $('#<%=ddlClients.ClientID %> option:selected').val();

        if (selectedClientId != -1) {
            //$.ajaxSetup({ async: false });
            $.getJSON("People.svc/getpeople", { ClientId: selectedClientId }, function (json) {
                availableTags = json;
            });
            //$.ajaxSetup({ async: true });

            $('#tbSearch').autocomplete({
                source: availableTags,
                minLength: 2
            });
        }
    });
});

The only thing I came up with was to disable async post backs while calling getJSON (which I commented out above), but I feel like this is a hack.

Considering how common WCF REST services and jQuery/Ajax are, I betting there’s another solution to this – or is disabling async postbacks the right way?

  • 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-10T00:55:11+00:00Added an answer on June 10, 2026 at 12:55 am

    You are trying to use the availableTags before it is assigned, the success function will be called when your request is completed, the code after the getJSON call will be executed immediately. Ti use the data returned by the success callback I suggest you put your code in the callback itself.

    $(document).ready(function () {
        var availableTags = "";
        $('#<%=ddlClients.ClientID %>').change(function () {
            var selectedClientId = $('#<%=ddlClients.ClientID %> option:selected').val();
    
            if (selectedClientId != -1) {
                //$.ajaxSetup({ async: false });
                $.getJSON("People.svc/getpeople", { ClientId: selectedClientId }, function (json) {
                    availableTags = json;
                    $('#tbSearch').autocomplete({
                        source: availableTags,
                        minLength: 2
                    });
                });
                //$.ajaxSetup({ async: true });
    
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF Syndication Service that works fine when run locally on Windows
WCF REST service works great in a way that it will reply/accept JSON or
I have a WCF rest service using webHttpBinding that returns JSON result. The problem
I have a wcf REST application hosted on IIS. Everything works fine, GET and
If I have a wcf rest service such as http://somedomain.com/service.svc/uniqueid/somemethod/parameter1 then is there a
I am writing a WCF REST service, and I am needing to generate my
I created a WCF rest service, then called that from javascript using ajax. Now
There is a WCF REST service hosted in Windows Service or in command line
So I have wcf rest service which succesfuly runs from a console app, if
I am trying to consume a wcf rest service via reflection if possible. Take

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.