Guest User

index.jsp

a guest
Sep 1st, 2010
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.60 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2.     pageEncoding="ISO-8859-1"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>Insert title here</title>
  8. <script type="text/javascript" src="xhr.js"></script>
  9. </head>
  10. <body>
  11. <h1 id="i1"></h1>
  12. <script type="text/javascript">
  13.     new XHR( {
  14.         url : "/testjersey/service/agenda/ping",
  15.         dest : document.getElementById("i1")
  16.     }).carregar();
  17. </script>
  18. <button id="b1">buscar contatos</button>
  19. <script type="text/javascript">
  20.     var x1 = new XHR( {
  21.         url : "/testjersey/service/agenda"
  22.         //accept : "application/json"
  23.     });
  24.     x1.oparam.hook = function(retr) {
  25.         alert(retr);
  26.     };
  27.     document.getElementById("b1").onclick = function() {
  28.         x1.carregar();
  29.     };
  30. </script>
  31. <button id="b2">Enviar contato</button>
  32. <script type="text/javascript">
  33. var x2 = new XHR( {
  34.     url : "/testjersey/service/agenda",
  35.     method:"POST",
  36.     contentType : "text/xml",
  37.     sending:"<contato><id>17</id><nome>fulano 2</nome></contato>"
  38. });
  39. document.getElementById("b2").onclick = function() {
  40.     x2.carregar();
  41. };
  42. </script>
  43. <button id="b3">deletar contato 3</button>
  44. <script type="text/javascript">
  45. var x3 = new XHR( {
  46.     url : "/testjersey/service/agenda/3",
  47.     method:"DELETE",
  48.     contentType : "text/xml"//o default do componente tรก form, mas o serviรงo espera text/xml
  49. });
  50. x3.oparam.hook=function(){
  51.     alert("done!");
  52. };
  53. document.getElementById("b3").onclick = function() {
  54.     x3.carregar();
  55. };
  56. </script>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment