
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 1.12 KB | hits: 33 | expires: Never
consume webservice using dojo
dojo.query("li").onclick(function(){
var xhrArgs = {
url: "http://192.168.1.65:9080/RAD8JAX-RSWeb/jaxrs/customers",
handleAs: "json",
headers: { "Content-Type": "application/json"},
load: function(data) {
alert("ok");
console.log(data);
},
error: function(error) {
console.log(error);
}
};
dojo.xhrGet(xhrArgs);
console.log("message sent ...");
});
// Create the store for later use
var store = new dojo.data.ItemFileReadStore({
contentType: 'application/json'
,clearOnClose: true
,urlPreventCache: true
,url: "http://192.168.1.65:9080/RAD8JAX-RSWeb/jaxrs/customers"
});
store.fetch({
onItem: function(item, request) {
alert('I fire after each returned json item')
}
,onComplete: function(items, findResult) {
alert('I fire when the data has loaded completely.');
}
,onError: function(error, request) {
alert('I fire when an error occurs');
}
});
store.close();