I used Ajax POST to update a JSON object but when I tried to retrieve the JSON object simultaneously after that, it returned the old data of the JSON object.
How do I delete this old object and always retrieve the new one? This how the GET looks like:
In addition I want to have the ability to :
- send a message and update a msg list jSON object.
- Immediately call GET to retrieve the object with a new updated data.(the one with new added message).
here is POST method code :
this.sendMessage = function(params)
{
var url = baseURL+"/direct/forum_message/sendMessage";
if(!params){
params = {'sakai.session': sessionId, 'siteId': siteId, 'toolId':toolId};
}
else
{
params.sessionId = sessionId;
params.siteId = siteId;
params.toolId = toolId;
}
var ret = false;
var ajaxOptions = {
url: url,
data: params,
type: "POST",
traditional: true,
async: false,
complete: function(data){
if(data.status == 0 || data.status == 200 || data.status == 201)
{
ret = $.parseJSON(data.responseText);
}
}
};
$.ajax(ajaxOptions);
return ret;
}
and GET method:
this.getListOfMessagesForSite = function()
{
var url = baseURL+"/direct/forum_message/getListOfMessagesForSite/"+siteId+".json";
var params = (sessionId != "") ? {'sakai.session': sessionId} : null;
var ret = null;
var ajaxOptions = {
url: url,
data: params,
type: "GET",
dataType: "json",
async: false,
complete: function(data){
if(data.status == 0 || data.status == 200 || data.status == 201)
{
ret = $.parseJSON(data.responseText);
}
}
};
$.ajax(ajaxOptions);
return ret;
}
My shot in the dark is the cache option: