I have two function with which I am handling the store and remove data by calling service end points. Below mentioned code will first check whether the data with the key mentioned is available or not.
RemoteDataStore.prototype.get = function(key,cb){
$.get(this.serverUrl + "?emailAddress=" + key ,function(serverResponse){
console.log(serverResponse);
cb(serverResponse);
});
};
And in the below mentioned code, I want to check whether the specified key is available or not. Based on that I will invoke the service end point to delete that specific data.
RemoteDataStore.prototype.remove = function(key){
this.get(key,function(serverResponse){
_id = serverResponse[0]["id"];
});
console.log("The id to remove is :" + _id);
/*$.ajax(this.serverUrl + "/" + key ,{
type: "DELETE"
});*/
};
The way I passed the parameters to the get function is not working. With this code,serverResponse is not available in remove function. serverResponse is the array of JSON objects returned by the service. What's the possible way to access the serverResponse variable inside remove function without changing get function?