Guest User

Untitled

a guest
Dec 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. http://www.test.com/test.html
  2.  
  3. <script language="JavaScript"><!--
  4.  
  5. xhr.onreadystatechange = function() {
  6.  
  7. if(xhr.readyState === 4 && xhr.status === 200) {
  8.  
  9. $responce = window.sessionStorage.getItem('responce');
  10.  
  11. var xhr = new XMLHttpRequest();
  12. xhr.open('POST', 'https://server.com/send2');
  13. xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
  14. xhr.send('responce=$responce');
  15.  
  16. }
  17. }
  18.  
  19. </script>
  20.  
  21. <form action="https://server.com/send1" method="post">
  22. <input name="USER" id="USER" type="hidden" value=""/>
  23. <input name="PWD" id="PWD" type="hidden" value="" />
  24. <input type="submit" value="送信">
  25. </form>
  26.  
  27. url: https://server.com/send1
  28.  
  29. 画面表示:responce=23swde7688j9jse
  30.  
  31. <script type="text/javascript">
  32. var xhr = new XMLHttpRequest();
  33. var send_flag = false;
  34.  
  35. xhr.onreadystatechange = function() {
  36. switch ( xhr.readyState ) {
  37. case 0:
  38. console.log( '未初期化' );
  39. break;
  40. case 1:
  41. console.log( '送信中' );
  42. break;
  43. case 2:
  44. console.log( '待ち' );
  45. break;
  46. case 3:
  47. console.log( '受信中:'+xhr.responseText.length+' bytes.' );
  48. break;
  49. case 4:
  50. if( xhr.status == 200) {
  51. var data = xhr.responseText;
  52. console.log( '受信完了:'+data );
  53. if(send_flag){
  54. var xhr2 = new XMLHttpRequest();
  55. send_flag = false;
  56. xhr2.open( 'POST','/send2/', false );
  57. xhr2.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
  58. xhr2.send('USER=u1&PWD=p1');
  59. xhr2.abort();
  60. }
  61.  
  62.  
  63. } else {
  64. console.log( '失敗しました: '+xhr.statusText );
  65. }
  66. break;
  67. }
  68. };
  69.  
  70. function send1(){
  71. send_flag = true;
  72. xhr.open( 'POST','/send1/', false );
  73. xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
  74. xhr.send('USER=u1&PWD=p1');
  75. xhr.abort();
  76. }
  77.  
  78.  
  79. </script>
  80. <input type="submit" value="送信" onclick="send1()">
Add Comment
Please, Sign In to add comment