Why jQuery.data does not work?
<p>Here is Javascript code from some HTML page I'm working on:</p>

<pre><code>var widgetsList = $("[widgetId]");
ToLogger("Init: " + widgetsList.length + " widgets found.");
for (var i=0; i&lt;widgetsList.length; i++)
{
  var widget = widgetsList[i];
  var jqID = "#" + widget.id;

  var refreshInterval = $(jqID).attr("refreshInterval");
  if (refreshInterval == undefined)
    refreshInterval = "30";

  $(jqID).data("refreshCounter", "0");
  var x = $(jqID).data("refreshCounter");
  ToLogger(" = widget[ " + widget.id + " ].refreshCounter(init1) = " + x);

  var widgetObj = $(jqID);
  jQuery.data(widgetObj, "refreshCounter", "0");
  x = jQuery.data(widgetObj, "refreshCounter");
  ToLogger(" = widget[ " + widget.id + " ].refreshCounter(init2) = " + x);
}
</code></pre>

<p>But in a log output I see:</p>

<pre><code>DashboardInit: 1 widgets found.
= widget[ Q.RecordCounters ].refreshInterval = 30
= widget[ Q.RecordCounters ].refreshCounter(init1) = undefined
= widget[ Q.RecordCounters ].refreshCounter(init2) = 0
</code></pre>

<p>Why the '$(jqID).data("refreshCounter")' returns 'undefined'?
A month ago exactly this javascript code was worked fine! What could be wrong now with it?
I have tried it with jQuery 1.7.2 and 1.8.1 - works the same way.
Could it be because of browser updated? (Firefox 15.0)</p>

<p>Next problem - even the jQuery.data(...) does not work in a timer function:</p>

<pre><code>var timerLock = false;
function OnTimer()
{
  if (timerLock) return ;
  timerLock = true;
  for (var i=0; i&lt;widgetsList.length; i++)
  {
    var widget = widgetsList[i];
    var jqID = "#" + widget.id;
    var widgetObj = $(jqID);
    var x = jQuery.data(widgetObj, "refreshCounter");
    var counter = parseInt(x);
    ToLogger(" = widget[ " + widget.id + " ].refreshCounter = " + x + " / " + counter);
  }
}
</code></pre>

<p>But in a log output I see:</p>

<pre><code>= widget[ Q.RecordCounters ].refreshCounter = undefined / NaN
</code></pre>

<p>Why 'undefined'?! If .data("refreshCounter") was successfully assigned before then I assume it must not be an 'undefined'.
Do you see - what could be wrong with it? </p>
