index.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <style>
  2. .css-input {
  3. margin-bottom: 0;
  4. text-shadow: 0px 0px 0px rgba(42, 42, 42, .75);
  5. text-align: left;
  6. border-radius: 8px;
  7. border-width: 3px;
  8. border-style: solid;
  9. background-color: #ffffff;
  10. border-color: #419fd1;
  11. box-shadow: -7px 0px 10px 0px rgba(7, 76, 214, .0);
  12. font-weight: normal;
  13. font-family: sans-serif;
  14. font-size: 16px;
  15. width: 500px
  16. }
  17. .css-input:focus {
  18. outline: none;
  19. }
  20. .btn {
  21. display: inline-block;
  22. padding: 6px 12px;
  23. margin-bottom: 0;
  24. font-size: 14px;
  25. font-weight: 400;
  26. line-height: 1.42857143;
  27. text-align: center;
  28. white-space: nowrap;
  29. vertical-align: middle;
  30. -ms-touch-action: manipulation;
  31. touch-action: manipulation;
  32. cursor: pointer;
  33. -webkit-user-select: none;
  34. -moz-user-select: none;
  35. -ms-user-select: none;
  36. user-select: none;
  37. background-image: none;
  38. border: 1px solid transparent;
  39. border-radius: 4px;
  40. color: #fff;
  41. background-color: #337ab7;
  42. border-color: #2e6da4;
  43. margin-left: 10px;
  44. }
  45. </style>
  46. <script type="text/javascript">
  47. $(document).ready(function () {
  48. $("#button").click(function () {
  49. if($("#url").val() == '') return false;
  50. $.ajax({
  51. //cache: true,
  52. type: "POST",
  53. url: 'u2s.php',//提交的URL
  54. data: $('#shorturl').serialize(), // 要提交的表单,必须使用name属性
  55. //async: false,
  56. success: function (data) {
  57. var parsedJson = jQuery.parseJSON(data);
  58. if(parsedJson.status == 1){
  59. var msg = parsedJson.url
  60. }else if(parsedJson.status == 0){
  61. msg = parsedJson.msg
  62. }
  63. $("#res").val(msg);
  64. },
  65. error: function (request) {
  66. alert("Connection error");
  67. }
  68. });
  69. return false;
  70. });
  71. });
  72. </script>
  73. <h2>请输入需要转换的网址</h2>
  74. <form id="shorturl" action method="POST">
  75. <input type="text" id="url" name="url" class="css-input">
  76. <button class="btn" id="button">提交</button>
  77. </form>
  78. <div>
  79. <input id="res" readonly="true" placeholder="输出结果" />
  80. </div>