Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <head>
  2. <script src="....">
  3. $(document).ready(function()
  4. {
  5. $("button").click(function()
  6. {
  7. $.post("AjaxpostloginServlet.java",
  8. {
  9. name:"kevin",
  10. pass:"Duckburg"
  11. });
  12. });
  13. });
  14. </script>
  15.  
  16. <body>
  17. <h2>Sending data to server using ajax post() method</h2>
  18. <button>submit to server</button>
  19. </body>
  20. </html>
  21.  
  22. --> Here's the servlet code
  23.  
  24.  
  25. package com.iappuniverse.ajaxpostlogin;
  26.  
  27. import java.io.IOException;
  28. import javax.servlet.http.*;
  29.  
  30. @SuppressWarnings("serial")
  31. public class AjaxpostloginServlet extends HttpServlet
  32. {
  33. public void doPost(HttpServletRequest req, HttpServletResponse resp)throws IOException
  34. {
  35.  
  36. String name=req.getParameter("name");
  37.  
  38. System.out.println(name);
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement