Here is the Laravel code snippet:
public function validateRegisterToBidForm(Request $request){
$validationArray = $this->getValidationArray();
$this->validate($request, $validationArray);
return response()->json();
}//validateRegisterToBidForm
The output from the above code is retrieved via Ajax. In case of an error, the output is stringified and returns a JSON like this:
{"readyState":4,"responseText":"{\"fname\":[\"This field is missing or incorrect.\"],\"lname\":[\"This field is missing or incorrect.\"],\"email\":[\"This field is missing or incorrect\"],\"password\":[\"This field is missing or incorrect.\"],\"adr1\":[\"This field is missing or incorrect.\"],\"city\":[\"This field is missing or incorrect.\"],\"state\":[\"This field is missing or incorrect.\"],\"phone\":[\"This field is missing or incorrect.\"],\"primary_phone\":[\"This field is missing or incorrect.\"],\"pass_dri_license\":[\"This field is missing or incorrect.\"],\"card_type\":[\"This field is missing or incorrect.\"],\"cardno\":[\"This field is missing or incorrect\"],\"cvv\":[\"This field is missing or incorrect.\"],\"fname_b\":[\"This field is missing or incorrect.\"],\"lname_b\":[\"This field is missing or incorrect.\"],\"email_b\":[\"This field is missing or incorrect.\"],\"adr1_b\":[\"This field is missing or incorrect.\"],\"city_b\":[\"This field is missing or incorrect.\"],\"state_b\":[\"This field is missing or incorrect.\"],\"phone_b\":[\"This field is missing or incorrect.\"],\"primary_phone_b\":[\"This field is missing or incorrect.\"]}","status":422,"statusText":"Unprocessable Entity"}
Now the question arises: How can we extract values from this JSON object? What would be the correct method?