Advertisement
Guest User

Demo

a guest
Sep 27th, 2015
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.52 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <title>Demo</title>
  6. </head>
  7. <body>
  8.     <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
  9.     <script>
  10.  
  11.     $( document ).ready(function() {
  12.    
  13.         $( "#but1" ).click(function( event ) {
  14.  
  15.         // 127.0.0.1:8080 - Адрес, который слушает наш сервер.
  16.         // cmd и LabelData - POST data, которая передаётся серверу при запросе.
  17.  
  18.         $.post( "http://127.0.0.1:8080/", { cmd: "PrintLabel", LabelData: "template=label4;barcode=1234567890;text=MyTestItem" })
  19.           .done(function( data ) {
  20.            
  21.             if ( data == "_print_ok" ) {      
  22.               alert("Print command - success");      
  23.             } else {
  24.               alert("Print command failed: " + data);    
  25.             }
  26.            
  27.           });
  28.  
  29.         });
  30.  
  31.         $( "#but2" ).click(function( event ) {
  32.  
  33.         $.post( "http://127.0.0.1:8080/", { cmd: "ClearQueue", printer: "default" })
  34.           .done(function( data ) {
  35.  
  36.             if ( data == "_clear_ok" ) {      
  37.               alert("Clear command - success");      
  38.             } else {
  39.               alert("Clear command failed: " + data);    
  40.             }
  41.            
  42.           });
  43.  
  44.         });
  45.        
  46.     });
  47.  
  48.     </script>
  49.    
  50.     <input type="button" value="Print" id="but1" /> &nbsp;&nbsp;&nbsp;&nbsp;
  51.  
  52.     <input type="button" value="Clear Printing queue" id="but2" />
  53.        
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement