Advertisement
lessientelrunya

ajax2

Jul 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.     <head>
  5.         <script src="https://code.jquery.com/jquery-latest.min.js"></script>
  6.         <script>
  7.  
  8.             function quote()
  9.             {
  10.                 var url = '/quote?symbol=' + $('#symbol').val();
  11.                 $.getJSON(url, function(data) {
  12.                     $('#quote').html('A share of ' + data.name + ' costs $' + data.price + '.');
  13.                     $('#symbol').val('');
  14.                 });
  15.             }
  16.  
  17.         </script>
  18.         <title>ajax2</title>
  19.     </head>
  20.     <body>
  21.         <form onsubmit="quote(); return false;">
  22.             <input autocomplete="off" autofocus id="symbol" placeholder="Symbol" type="text"/>
  23.             <input type="submit" value="Get Quote"/>
  24.         </form>
  25.         <p id="quote"></p>
  26.     </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement