Calling WCF service with jquery and parameters synchronously

I am calling a .NET WCF service from Ajax like this:

result = $.ajax({
    type: "POST",
    // async: false,
    contentType: "application/json; charset=utf-8",
    url: BaseUrl + "Services/YucataService.svc/SetGameStatusSecure",
    data: "{'gameID':'" + gameID + "','pid':'" + pid + "','status':'" + newStatus + "','origStatus':'" + oldStatus + "'}",
    dataType: "json",
    timeout: 20000
});

The server part looks like this:

[OperationContract]
public void SetGameStatusSecure(int gameID, int pid, string status, string origStatus)
{
   ... magic stuff happens
}

It works well.

Now, I would like to call the service synchronously. The only change I do is to add "async: false". The call return with status 500 (=internal server error).

Do I have to configure the WCF service differently to allow sync calls?

Before I switched to WCF I used an .asmx service to call synchronously and I didn't have any issues.

Any ideas?

Answers


I think by default WCF accepts Synchronous calls. If you want to make it asynchronous, you need make sure you check “Generate asynchronous operations” under Advanced tab. (at the time of adding service reference). Be default, this check box is always unchecked.


Need Your Help

Twython get followers count

python twitter twython

Is there an easy way to get the number of followers an account has without having to loop through cursors? I'm looking for a simple function call which will return to me just the number of follower...

Unable to interact with third party angularJs application with phantomJs,capybara

angularjs phantomjs capybara poltergeist

I am unable to interact with angularjs third party application. I have installed capybara-ng, capybara/angularjs and have changed the DSL to angularJs DSL.