Answers.Body: <p>Currently the users/saveUser (and the deprecated users/setPassword) controller action doesn’t support Ajax requests, so there won’t really be an easy way to tell if it worked or not.</p>
  
  <p>If you really want to update user passwords over Ajax, your best bet will be to write a plugin with its own custom controller action, which mimics the password-related stuff in <a href="http://buildwithcraft.com/classreference/controllers/UsersController#actionSaveUser-detail" rel="nofollow">UsersController::actionSaveUser()</a>, but probably calls <a href="http://buildwithcraft.com/classreference/services/UsersService#changePassword-detail" rel="nofollow">UsersService::changePassword()</a> rather than <a href="http://buildwithcraft.com/classreference/services/UsersService#saveUser-detail" rel="nofollow">saveUser()</a> since you only care about updating the password. And have that controller respond with JSON if it’s an Ajax request, rather than assuming it’s not.</p>
  
  <p>Take a look at <a href="http://buildwithcraft.com/classreference/controllers/EntriesController#actionSaveEntry-detail" rel="nofollow">EntriesController::actionSaveEntry()</a> for an example of a controller action that <em>does</em> support Ajax.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-18T20:27:48.887Z
Answers.Text: Okay, thanks for the answer. I don't have to use ajax, think I'll stick to regular post.
Answers.UserDisplayName: Espen Sandberg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-18T14:10:41.640Z
Answers.LastActivityDate: 2014-09-18T14:10:41.640Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I'm building a profile page for members on a site where members can change their password. I'm sending the request with ajax, and can successfully change password if I have the input name "password" correct with the users current password.</p>
  
  <p>My problem is that I get a success-response, when I should have gotten an error-response. (Password isn't changed, but I have no way of telling the user there was en error).</p>
  
  <p>My JS is something like this:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "",
      data: dataString,
      success: function(data) {
          console.log("Password successfully changed");
      },
      error: function(data) {
          console.log("Error. Password did not change");
      }
  });
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-18T09:59:47.557Z
Comments.Text: Haven't actually tested anything yet, but it looks like it should return errors if there is any problems. Have you had a look at UsersController@actionSaveUser?
Comments.UserDisplayName: Fred Carlsen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-18T10:03:17.337Z
Comments.Text: Just to clarify: You say "and can successfully change password if I have the input name". That means it works, given that the right password is entered, right? In the second paragraph, do you mean you get an success-response, even if there is an error? See anything in the log?
Comments.UserDisplayName: Fred Carlsen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-18T11:21:21.823Z
Comments.Text: @FredCarlsen Correct. It works if the given password is entered. So far, so good. My problem is I don't get error-response. I can't see anything in the log.
Comments.UserDisplayName: Espen Sandberg
Tags: <ajax><user-profile><password>
Title: Change user password on the front end
ThreadText: # Change user password on the front end
  
  (Asked by: username_0 on 2014-09-18)
  
  I'm building a profile page for members on a site where members can change their password. I'm sending the request with ajax, and can successfully change password if I have the input name "password" correct with the users current password.
  
  My problem is that I get a success-response, when I should have gotten an error-response. (Password isn't changed, but I have no way of telling the user there was en error).
  
  My JS is something like this:
  
  ```
  $.ajax({
      type: "POST",
      url: "",
      data: dataString,
      success: function(data) {
          console.log("Password successfully changed");
      },
      error: function(data) {
          console.log("Error. Password did not change");
      }
  });
  
  ```
  
  **Tags:** ajax, user-profile, password
  
  > **Comments:**
  > **username_1**: Haven't actually tested anything yet, but it looks like it should return errors if there is any problems. Have you had a look at UsersController@actionSaveUser?  
  > **username_1**: Just to clarify: You say "and can successfully change password if I have the input name". That means it works, given that the right password is entered, right? In the second paragraph, do you mean you get an success-response, even if there is an error? See anything in the log?  
  > **username_0**: @username_1 Correct. It works if the given password is entered. So far, so good. My problem is I don't get error-response. I can't see anything in the log.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-09-18. Score: 3 | Accepted answer
  
  Currently the users/saveUser (and the deprecated users/setPassword) controller action doesn’t support Ajax requests, so there won’t really be an easy way to tell if it worked or not.
  
  If you really want to update user passwords over Ajax, your best bet will be to write a plugin with its own custom controller action, which mimics the password-related stuff in [UsersController::actionSaveUser()](http://buildwithcraft.com/classreference/controllers/UsersController#actionSaveUser-detail), but probably calls [UsersService::changePassword()](http://buildwithcraft.com/classreference/services/UsersService#changePassword-detail) rather than [saveUser()](http://buildwithcraft.com/classreference/services/UsersService#saveUser-detail) since you only care about updating the password. And have that controller respond with JSON if it’s an Ajax request, rather than assuming it’s not.
  
  Take a look at [EntriesController::actionSaveEntry()](http://buildwithcraft.com/classreference/controllers/EntriesController#actionSaveEntry-detail) for an example of a controller action that *does* support Ajax.
  
  > **Comments:**
  > **username_0**: Okay, thanks for the answer. I don't have to use ajax, think I'll stick to regular post.  
  
  ---
  
  