JQuery how to read this JSON string from responseText

I tried almost everything here, on a stack overflow, but for some reason I cannot read the JSON string data returned from the success function call in jquery ajax. my success function gets the following JSON string:

Object {
  readyState = 4, responseText = "{"
  Response ":200,"
  Data ":"
  6 ","
  Message ":"
  6 "}", status = 200, statusText: "OK"
}

This is my successful callback:

success: function(response, msg, responseText) {
   if (response.Response == 200) {
     console.log("Data was submitted");
     var obj = responseText;

     console.log(typeof obj);
   } else if (response.Response == 400) {
     console.log("there was some error");
   }
 }

When the success function is started and checks the status code, it executes console.log ("Data has been sent"); the expression is successful, however, I cannot access the "Data": the key / value pair is "6".

So far I have tried to do this:

var obj = responseText;
console.log(obj.Data);

and

console.log(obj.data[1]);

and many other ways, but either he says "undefined" or gives errors. However, when I console.log (obj), "obj" is displayed in the console. which means i get a json object.

Please note that I also tried:

obj = jQuery.parseJSON(responseText);

: SyntaxError: JSON.parse: 1 2 JSON

? , "": value = "6" .

+4
2

- , , . , . , - 200 . , error , , 400 .

:

dataType: 'json',
success: function (response) {
    console.log("Data was submitted");
    console.log(response.Data);
},
error: function() {
    console.log("there was some error");
}
+4
+1

Source: https://habr.com/ru/post/1621477/


All Articles