Reading JSON with JQuery
Posted
by user70192
on Stack Overflow
See other posts from Stack Overflow
or by user70192
Published on 2010-03-24T14:20:24Z
Indexed on
2010/03/24
14:23 UTC
Read the original article
Hit count: 304
Hello,
I am using JQuery to execute an operation within a web service. After writing data back to my databaes, the service returns a JSON response. My request looks like the following:
$.ajax({
url: "/services/myService.svc/PostMessage",
type: "POST",
contentType: "application/json; charset=utf-8",
data: '{"message":"testing","comments":"test"}',
dataType: "json",
success: function (response) {
if ((response.d != null) && (response.d.length > 0)) {
// Parse the status code here
}
else { alert("error!"); }
},
error: function (req, msg, obj) {
alert("error: " + req.responseText);
}
});
When my response is returned, response.d contains the following:
[{"StatusCode":1}]
How do I parse out the value of the StatusCode?
© Stack Overflow or respective owner