title: Passing custom success/error messages to ajax call from asp.net controller
body: <p>Im working with ASP.Net Core and I'm trying to have everything localized. I have no isses localizing strings from the controller or right in the view but I do have an ajax call from javascript that currently has hard coded english success/error messages. My initial thought is I could just pass the localized success/error message back to the ajax call from the controller. I'm thinking this will be easy enough with the ajax success function but Im not really sure how to pass an error message to the error/fail function. </p>
  
  <p>Here is my ajax call:</p>
  
  <pre><code>$.ajax({
   type: "POST",
   url: '@Url.Action("SaveGridState", "Account", new { gridID = 3 })',
   data: {
     options: JSON.stringify(gridState)
   },
   async: true,
   success: function(data) {
     var staticNotification = $("#staticNotification").data("kendoNotification");
  
     staticNotification.show({
       message: "Grid State Saved"
     }, "success");
  
     var container = $(staticNotification.options.appendTo);
     container.scrollTop(container[0].scrollHeight);
   },
   fail: function() {
     var staticNotification = $("#staticNotification").data("kendoNotification");
      staticNotification.show({
       message: "Grid State Save Failed"
      }, "error");
  
     var container = $(staticNotification.options.appendTo);
     container.scrollTop(container[0].scrollHeight);
   }
  });
  </code></pre>
  
  <p>Here is my function from my controller:</p>
  
  <pre><code>public bool SaveGridState(string options, int gridID)
      {
          try
          {
              UserStore ustore = new UserStore(_settings);
              HttpContext.Session.LoadAsync();
              uint user_id = (uint)HttpContext.Session.GetInt32("UserID");
  
              options = options.Replace("'", @"\'");
  
              return ustore.SaveGridState(user_id, gridID, options);
          }
          catch(Exception ex)
          {
              return false;
          }           
      }
  </code></pre>
  
  <p>Is there a way to define my success/error message from the SaveGridState function and pass it to the ajax function?</p>