Guest User

Untitled

a guest
Apr 25th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. consume webservice using dojo
  2. dojo.query("li").onclick(function(){
  3. var xhrArgs = {
  4. url: "http://192.168.1.65:9080/RAD8JAX-RSWeb/jaxrs/customers",
  5.  
  6. handleAs: "json",
  7. headers: { "Content-Type": "application/json"},
  8. load: function(data) {
  9. alert("ok");
  10. console.log(data);
  11. },
  12. error: function(error) {
  13. console.log(error);
  14. }
  15. };
  16. dojo.xhrGet(xhrArgs);
  17. console.log("message sent ...");
  18. });
  19.  
  20. // Create the store for later use
  21. var store = new dojo.data.ItemFileReadStore({
  22. contentType: 'application/json'
  23. ,clearOnClose: true
  24. ,urlPreventCache: true
  25. ,url: "http://192.168.1.65:9080/RAD8JAX-RSWeb/jaxrs/customers"
  26. });
  27.  
  28. store.fetch({
  29. onItem: function(item, request) {
  30. alert('I fire after each returned json item')
  31. }
  32. ,onComplete: function(items, findResult) {
  33. alert('I fire when the data has loaded completely.');
  34. }
  35. ,onError: function(error, request) {
  36. alert('I fire when an error occurs');
  37. }
  38. });
  39.  
  40. store.close();
Advertisement
Add Comment
Please, Sign In to add comment