0

We have a spa(single page application) created using CefSharp and knockoutJS. It has few subscribe methods defined. We populate the data in an accordion control through ajax request. So when we click on a field in accordion the observable property is set with a value which in turn invoke a subscribe method and inside this subscribe method we have made synchronous call to a C# method. Before the synchronous call we have made the loading panel to visible, but it is not displaying the loading panel. Is it possible to display the loading panel on synchronous call?

Ben
  • 53
  • 1
  • 6
  • 2
    Any reason it has to be a synchronous call? I'd question the need for it in the majority of cases. – Paul Manzotti Feb 12 '15 at 14:04
  • first thing here it wont display loading if a call is sync (it may come but comes at the ends like a flash and goes of) and can't agree more to @PaulManzotti comment . – super cool Feb 12 '15 at 15:17

1 Answers1

0

When any JavaScript code is executing on browser synchronously, the UI won't be updated until the code has finished executing. Hence, the answer to your question is 'It is not possible'. This is not a Knockout issue.

As others have commented, are you sure you want to make it a synchronous call? This approach is advised against, and now deprecated: see jQuery has deprecated synchronous XMLHTTPRequest

Make the call asynchronous, and if necessary disable other screen elements during the execution (e.g. to prevent multiple presses of buttons).

Community
  • 1
  • 1
Quango
  • 12,338
  • 6
  • 48
  • 83