1
0

login.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. function sendXHR(options)
  2. {
  3. // (Modern browsers) OR (Internet Explorer 5 or 6).
  4. newXHR = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP");
  5. if(options.sendJSON === true)
  6. {
  7. options.contentType = "application/json; charset=utf-8";
  8. options.data = JSON.stringify(options.data);
  9. }
  10. else
  11. {
  12. options.contentType = "application/x-www-form-urlencoded";
  13. }
  14. newXHR.open(options.type, options.url, options.async || true);
  15. newXHR.setRequestHeader("Content-Type", options.contentType);
  16. newXHR.send((options.type == "POST") ? options.data : null);
  17. newXHR.onreadystatechange = options.callback; // Will executes a function when the HTTP request state changes.
  18. return newXHR;
  19. }
  20. $(document).ready(function()
  21. {
  22. $('#loginForm').live('submit', function(e)
  23. {
  24. e.preventDefault();
  25. $.post('includes/func_login.php', $(this).serialize(), function (data, textStatus)
  26. {
  27. if(data == "true")
  28. {
  29. window.document.location = "./panel/characters";
  30. }
  31. else
  32. {
  33. $('#app-alerts').html(data);
  34. $(document).ready(function(){
  35. $('.message_pop_n').delay(5000).fadeOut(300);
  36. });
  37. }
  38. });
  39. return false;
  40. });
  41. });