Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autocomplete = "off" ignored in IE?

I have a form with checkboxes, with their 'checked' value being populated from code behind in a database.

Imagine, if I have checkboxes 1,2 and 3 all set to checked in the database. I load the page, uncheck checkbox 3 and then commit the changes to the database. Now in my database, checkboxes 1 and 2 are checked and 3 is unchecked. I refresh the page, it gets the updated database values and the checkboxes have the correct checked values.

This is only working for me in chrome and FF. In IE, even if I uncheck checkbox 3, commit the changes to the database and refresh, it still appears checked. I forced a refresh with ctrl+f5 and it still isn't updating. Adding autocomplete="off" to both the checkboxes and parent form did nothing.

like image 762
David James Ball Avatar asked Dec 05 '13 21:12

David James Ball


People also ask

Do browsers ignore autocomplete off?

One point worth mentioning is that many browser will ignore autocomplete settings for login fields (username and password). As the Mozilla article states: For this reason, many modern browsers do not support autocomplete="off" for login fields.

How do I force autocomplete off?

To disable the autocomplete of text in forms, use the autocomplete attribute of <input> and <form> elements. You'll need the "off" value of this attribute.


1 Answers

This question is already answered in comments but no relevant answer is provided in Answers. I am trying to answer it here so that it will be useful for all others users facing same issue.

The solution can be :

Consecutive ajax call with no change in request are often considered as cached by some browsers and this issue is particularly reproducible in IE 10. The response for request is HTTP 304 Not Modified and request doesn't hit the database. The solution is to use ajaxSetup to set cache to false like :

$(document).ready(function() {
  $.ajaxSetup({ cache: false });
});

NOTE: This will set cache false for all ajax calls in the session.

OR

Using cache: false in particular ajax calls, if you don't want to disable cache for all ajax calls.

$.ajax({
         ...
         cache: false,
         ...
      });
like image 138
Pranav Singh Avatar answered Sep 21 '22 17:09

Pranav Singh