Reputation: 29
var signal=jQuery.ajax({
url: "http://###/user/checkcaslogin.aspx",
dataType: "json",
success: function(data){
}
});
I want to Convert responseText
into a JSON object, I have tried JSON.parse() but
and typeof signal.responseText //String
Upvotes: 0
Views: 2318
Reputation: 943152
If you want to parse the response text as JSON, first you have to send JSON in the response.
JSON Lint is a useful tool for debugging this sort of thing.
This is not valid JSON:
{ "code": 00 }
The Number data type in JSON cannot begin with a double zero.
After you fix the response, the success
function will fire, and data
will be the result of parsing the JSON.
Upvotes: 6
Reputation: 8324
The data
parameter is already an object, so you can just use it as object. If you prefer to get the JSON string for whatever reason, use JSON.stringify(data)
to get the JSON string.
Upvotes: 0