Advertisement
Guest User

ajax request

a guest
Jun 23rd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>SO question 4112686</title>
  5.     <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  6.     <script>
  7.         $(document).ready(function() {                      
  8.             $('#somebutton').click(function() {              
  9.                 $.get('GetUserServlet', function(responseText) {
  10.                     $('#somediv').text(responseText);        
  11.                 });
  12.             });
  13.         });
  14.  
  15.  
  16.         $("#somebutton").click(function(){
  17.          $.ajax({
  18.             url:'GetUserServlet',
  19.             data:{name:'abc'},
  20.             type:'get',
  21.             cache:false,
  22.             success:function(data){
  23.                alert(data);
  24.                $('#somediv').text(responseText);
  25.             },
  26.             error:function(){
  27.               alert('error');
  28.             }
  29.          }
  30.     );
  31. }
  32. );
  33.     </script>
  34. </head>
  35. <body>
  36.  
  37.     <button id="somebutton">press here</button>
  38.     <div id="somediv"> </div>
  39. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement