Parse JSON using JQuery -


I am getting a JSON string response from my WCF service. I want to parse this JSON for related items. That's why I did the following.

  $ Ajax ({type: 'GET', url: 'http: //URL/Service.svc/LoginValidation?', Success: function (response, position, xhr) {if (response! = "") {Var JSON = response .replace (/ ^ "$ / g, '\' '); // with single quotations, start and end replace with double quotation marks. JSON string should end with single quotes during start and end Var obj = JSON.parse (JSON); // This is my problem. While reaching the JSON variable here that automatically appears double quote, so speak here Showing configuration error. = Obj.UserID; ClientID = obj.ClientID; domain name = obj.DomainName; AuthenticationKey = obj.AuthenticationKey;} and {alert ( "Invalid user name or password.");}}});   

The way we can parse this JSON data, we can use it JQuery.

simply set dataType: 'json' your $ Ajax () in call options and jQuery will parse it and provide a decoded object to its success handler.

Comments