I am returning error message using ajax. the return object like below
{"readyState":4,"responseText":"{\"Message\":\"The request is invalid.\",\"ModelState\":{\"\":[\"Email 'dsfasdf' is invalid.\"]}}","responseJSON":{"Message":"The request is invalid.","ModelState":{"":["Email 'dsfasdf' is invalid."]}},"status":400,"statusText":"Bad Request"}
I want to know whether (showError.responseText).ModelState[""] is exist or not
I tried both following code. But doesn't work
if ((showError.responseText).ModelState[""]) {
console.log('Key is exist in Object!');
}
if ((showError).hasOwnProperty("ModelState[0]")) {
console.log('Key is exist in Object!');
}