maintopics.js 742 Bytes
function notify(msg) {
  $("#notifications").html(msg);
  $("#notifications").fadeIn(250).delay(3000).fadeOut(500);
}

function getCookie(name) {
  var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
  return r ? r[1] : undefined;
}

function change_password() {
  // alert('hello');
  // notify('hello!');
  var token = getCookie('_xsrf');
  $.ajax({
    type: "POST",
    url: "/change_password",
    headers: {'X-XSRFToken' : token },
    data: {
      "new_password": $("#new_password").val(),
    },
    dataType: "json",
    success: function(r) {
      notify(r['msg']);
    },
    error: function(r) {
      notify(r['msg']);
    },
  });
}

$(document).ready(function() {
  $("#change_password").click(change_password);
});