title: Ajax error function not calling in java
body: <p><strong>Ajax error function not calling in java</strong> </p>
  
  <p>Here is the ajax method:-</p>
  
  <pre><code>$.ajax({
      type:"post",
      timeout:5000,
      url:"&lt;s:property value="URL"/&gt;",
      data:{name:newName},
      success:function () {
          $("#errorDiv").html("Successfully updated");
      },
      error:function (data) {
          $("#errorDiv").html("Error.");
      }
  })
  </code></pre>
  
  <p>Update User method:-</p>
  
  <pre><code>    @Action(value = "renameUser", results = {@Result(name = "success", type = "json"),
      @Result(name = "input", type = "tiles", location = "view.list")},
              interceptorRefs = {@InterceptorRef("auditingAdminDefault")})
      @Override
      public String execute() throws Exception {
          String result = "input";
          try {
              updateUser(name);
              addActionMessage(name + " user name was successfully updated.");
              result = "success";
          } catch (Exception e) {
              addActionMessage(e.getMessage());
              result = "input";
          }
          return result;
      }
  }
  
  updateUser();
  
  updateUser() throws Exception {
  
  if (..) {
  
  } else {
    throw Exception();
  }
  </code></pre>
  
  <p><strong>I am able to update user successfully without issues. But success function is called for successful update or any error thrown.</strong></p>
  
  <p><strong>There are two things I need to use in Ajax.</strong></p>
  
  <ul>
  <li>Success and error method should be called based on result</li>
  <li>I need to catch the error from update user method and show it in UI.</li>
  </ul>
  
  <p><strong>Kindly anyone tell me what I am doing wrong here ?</strong></p>