login.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
  2. <script>
  3. $(function () {
  4. // 注册
  5. $("#login").click(function () {
  6. var form = $("#chatfrom").serializeArray();
  7. form.push({"name": "type", "value": "1"});
  8. $.ajax({
  9. type: 'POST',
  10. url: "chat.php",
  11. data: form,
  12. dataType: 'json',
  13. success: function (result) {
  14. var data = result;
  15. alert(123);
  16. alert(result.msg);
  17. if (result.errcode == 0) {
  18. window.location.href = window.location.href;
  19. }
  20. },
  21. error: function(jqXHR, textStatus, errorThrown) {
  22. /*弹出jqXHR对象的信息*/
  23. alert(jqXHR.responseText);
  24. alert(jqXHR.status);
  25. alert(jqXHR.readyState);
  26. alert(jqXHR.statusText);
  27. /*弹出其他两个参数的信息*/
  28. alert(textStatus);
  29. alert(errorThrown);
  30. },
  31. beforeSend: function () {
  32. //$("#alertActivityBtn").addClass("disabled");
  33. }
  34. });
  35. });
  36. /*// login
  37. $("#login").click(function () {
  38. var form = $("#chatfrom").serializeArray();
  39. form.push({"name": "type", "value": "2"});
  40. $.ajax({
  41. type: 'POST',
  42. url: "user.php",
  43. data: form,
  44. dataType: 'json',
  45. success: function (result) {
  46. alert(result.msg);
  47. if (result.errcode == 0) {
  48. window.location.href = window.location.href;
  49. }
  50. },
  51. beforeSend: function () {
  52. //$("#alertActivityBtn").addClass("disabled");
  53. }
  54. });
  55. });*/
  56. });
  57. </script>
  58. <div style="margin:0 auto;border:1px solid #000;width:300px;height:100px;margin-top: 300px">
  59. <form action="chat.php" method="post" id="chatfrom">
  60. <p>
  61. <input type="text" name="account"/>
  62. </p>
  63. <input type="password" name="paw"/>
  64. <!--<input type="submit" data-type=1 id="redc" value="注册"/>-->
  65. <input type="submit" name="login2" data-type=2 id="login2" value="登录"/>
  66. </form>
  67. </div>