password.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. function password_change() {
  2. $('#content').html('');
  3. $('#result').html('');
  4. var str = '<table border="1" width="100%">';
  5. str += '<tr><td colspan="2"><a href="#" id="put">put</a></td></tr>';
  6. str += '<tr><td>oldPassword:</td><td><input type="password" style="width:95%" id="oldPassword"/></td></tr>';
  7. str += '<tr><td>newPassword:</td><td><input type="password" style="width:95%" id="newPassword"/></td></tr>';
  8. str += '<tr><td>confirmPassword:</td><td><input type="password" style="width:95%" id="confirmPassword"/></td></tr>';
  9. str += '</table>';
  10. $('#content').html(str);
  11. $('#put').click(function() {
  12. password_put();
  13. });
  14. }
  15. function password_put() {
  16. $('#result').html('');
  17. $.ajax({
  18. type : 'put',
  19. dataType : 'json',
  20. url : '../jaxrs/password',
  21. contentType : 'application/json; charset=utf-8',
  22. data : JSON.stringify({
  23. oldPassword : $('#oldPassword').val(),
  24. newPassword : $('#newPassword').val(),
  25. confirmPassword : $('#confirmPassword').val()
  26. }),
  27. xhrFields : {
  28. 'withCredentials' : true
  29. },
  30. crossDomain : true
  31. }).done(function(json) {
  32. $('#result').html(JSON.stringify(json, null, 4));
  33. });
  34. }