I have called a ajax call for saving the data(140 sized characters) in to database and then again have a ajax call in success function of the first call.
It is working fine in FF i,e when click that button it will be saved and then retrieved that data successfully(I need this data to show with timestamp). But in IE it is working fine only one time, means when click button the a set of data will be saved and then show ,but again click button saving another set of data, but not showing that data ,it is showing previous data. any solution my code is
function save(){
$.ajax({
url : 'saveNote.html?note=' + notes,
success : function() {
// showNote(); //this is also not working in IE
setTimeout(function () { showNote(); }, 1000);
document.getElementById('notes').value="";
},
error: function (xhr, ajaxOptions, thrownError) {
alert('my error = ' + thrownError);
alert('my error1 = ' + ajaxOptions);
alert('my error2 = ' + xhr);
}
});
}
function showNote(){
$.ajax({
url : 'getNote.html',
method : "GET",
dataType: "json",
success : function(data) {
responseNote=data;
showLabel(responseNote);
},
error: function (xhr, ajaxOptions, thrownError) {
alert('my error = ' + thrownError);
alert('my error1 = ' + ajaxOptions);
alert('my error2 = ' + xhr);
}
});
}
IE is known to cache the AJAX requests. Thus subsequent request generates same output. There are a number of ways to overcome this problem. Here are some:
Source: Viralpatel’s Blogs
1. Attach random number with request
2. Attach date with request
3. Disable jQuery cache
I’ll suggest you to use 3rd option.
Hope this helps