I would like to begin with this. I am fed up with IE. I have the code below:
$(function () {
$("#cal").on('click', "#forward", function () {
$.ajax({
url: "Home/Calendar?target=forward",
type: "GET",
success: function (result) {
$("#cal").html(result);
}
});
});
});
$(function () {
$("#cal").on('click', "#backwards", function () {
$.ajax({
url: "Home/Calendar?target=backwards",
type: "GET",
success: function (result) {
$("#cal").html(result);
}
});
});
});
It is an ajax call to a controller action in an C# MVC application. It just goes back and forth a calendar's months replacing the html. Now I know that you need to reattach the event due to the html()
call and that is why I use on()
with JQuery 1.7. I have used delegate()
as well. In FF, Chrome it works as intended. In IE 10 it does not. I am at a loss. I knew that IE had issues with delegate in IE8 and with JQuery < 1.5 but this is not the case.
Does anyone know how to solve this?
ajax, which will allow you to turn caching off: $. ajax({url: "myurl", success: myCallback, cache: false});
Fact #1 : Ajax Caching Is The Same As HTTP Caching At this level, the browser doesn't know or care about Ajax requests. It simply obeys the normal HTTP caching rules based on the response headers returned from the server. If you know about HTTP caching already, you can apply that knowledge to Ajax caching.
We are required to set cookies with AJAX requests or in such a way that any AJAX request sends those cookies to the server. One thing to note here is that every AJAX request made to any remote server automatically sends all our cookies to that very server without us having to do anything.
I am answering the question just for future reference for other people. It seems that IE is caching AJAX requests for some reason I am unable to comprehend.
I noticed using the (surprisingly good) developer tools IE 10 provides that I was getting a 304 not modified response to my AJAX requests. This was not the case in Firefox or Chrome (200 was the response).
I added the cache: false
option to my AXAJ JQuery functions and now it works as intended.
IE never seizes to amaze me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With