views:

33

answers:

1

I have WCF service which communicates with SqlServer, and want to make frontend with JQuery. The question is: How can i catch WCF errors in JQuery code, such as failed connection or not existing database or some others.

PS. Maybe its better to use something like ASP.NET MVC with JQuery rather than pure JQuery?

A: 

We are also using jquery which communicates to WCF for one of our application. WCF exposes data as json object. Along with data it will have a response object which hold all information like failure , success etc. If its a failure it will have a message telling what type of expection it is.

For every result send a response object which can hold all info response code success failure expection details.

So that we can check that object and query the json object for data. please let me know if you need any furthur info on this.

gov
Can you provide some samples?
Viktor
Assume you call WCF with jquery and it return back the json object.In WCF you can expose the methods as Json objects which automatically converts lists to json objectsLets assume your json can result multple values.Employees --, this holds all the employee records like Employeep[0] Employeep[1] Employeep[2]Response Object Responsecode-- 200 or 500 etc ResponseMessage-- "Success" or Failure exceptions if anyWhich writing your back end WCF code , handle expections also whenever you have exception send the exception backto the UI.
gov
I need to to include additional field in response like "status = 201 for connection fault etc." and in JQuery check this field and make appropriate decision, am i right?
Viktor
Yes thats what i am doing right now.
gov