SyntaxError: JSON.parse: unexpected character in Zeile 1 der Spalte 2 des JSON-Daten

Controller

[HttpGet]
public ActionResult VerifyUserEmail(string User_Email)
{
  try
  {
    using (EmptyMVCApplicationEntities objConnection = new EmptyMVCApplicationEntities())
    {
      ObjectParameter objIErrorCode = new ObjectParameter("ErrorCode", typeof(Int32));  
      ObjectParameter objBFlag = new ObjectParameter("bFlg", typeof(bool));
      objConnection.Check_User_Exists(User_Email, objBFlag, objIErrorCode);
      if (Convert.ToBoolean(objBFlag.Value) != true)
      {
        return Json(new { Success = "false", Message = "Email exists" }, JsonRequestBehavior.AllowGet);
      }
      else
      {
        return Json(new { Success = "True", Message = "Email not exists" }, JsonRequestBehavior.AllowGet);
      }               
    }
  }
  catch (Exception Ex) 
  {    
  }
}

Skript

$("#User_Email").blur(function () {
  if ($(this).val() != "") {
    $.ajax({
      url: "/User/VerifyUserEmail?User_Email=" + $("#User_Email").val(),
      success: function (result) {
        try {
          var jsonIssueObj = $.parseJSON(result).Data;    
        }  catch (e) { alert(e); }
        if (!jsonIssueObj.Success) {
          var errorMsg = jsonIssueObj.Message;
          $('#msg').html(errorMsg);
          $('#msg').show();
        }
        else {
          var errorMsg = null;
          $('#msg').html(errorMsg);
          $('#msg').hide();
        }
      }
    });
  }
  return false;
});

Erhalte ich folgende Fehlermeldung:

SyntaxError: JSON.parse: unexpected character in Zeile 1 der Spalte 2 des JSON-Daten

Auch Wenn ich wollen den Erfolg und die Nachricht in ein Objekt, wie übergibt man ein Objekt als json-in-controller actionresult.

Schreibe einen Kommentar