title: RJS error: TypeError: element is null
body: <p>I got RJS error: TypeError: element is null while using ajax.</p>
  
  <p>I used  in view</p>
  
  <pre><code>&lt;%= periodically_call_remote(:url=&gt;{:action=&gt;'get_user_list', :id=&gt;'1'},
  :frequency =&gt; '5') %&gt;
  </code></pre>
  
  <p>in controller</p>
  
  <pre><code>  render :update do |page|
      page.replace_html  'chat_area', :partial =&gt; 'chat_area', :object =&gt; [@chats, @user]     if @js_update
    end
  </code></pre>
  
  <p>in partial chat_area</p>
  
  <pre><code>&lt;% if !@chats.blank? &amp;&amp; !show_div(@chats).blank?%&gt;
      &lt;% show_div_id=show_div(@chats) %&gt;
    &lt;% for chat in @chats %&gt;
        &lt;div class="popup" id="chat_area_&lt;%= chat.id %&gt;"
  style="display:&lt;%= (chat.id == show_div_id)? 'block' : 'none' %&gt;;"&gt;
  
          &lt;% form_remote_for(:chat, :url =&gt; {:controller=&gt;'chats',
  :action=&gt;'create', :id=&gt;1}, :html=&gt;{:name =&gt; "form_#{chat.id}"},
  :complete=&gt;"resetContent('#{chat.id}');") do |f| %&gt;
          &lt;div style="display:none;"&gt;
              &lt;%= f.hidden_field :sessionNo, :value=&gt;chat.sessionNo %&gt;
              &lt;%= f.text_area :chatContent,  :id=&gt;
  "chatContent_field_#{chat.id}", :cols=&gt;"100", :rows=&gt;"6",
  :onKeyPress=&gt;"return submitenter(this,event);" %&gt;
            &lt;/div&gt;
              &lt;input type="image" src="images/chat/send-hover.png"
  value="Send" onclick="return submit_button('&lt;%= chat.id %&gt;')"/&gt;
          &lt;% end %&gt;
        &lt;/div&gt;
  
      &lt;/div&gt;
    &lt;% end %&gt;
  
  &lt;% else %&gt;
        &lt;div class="popup" id="chat_area_none" style="display:'block';"&gt;
            &lt;input type="image" disabled ="disabled"
  src="images/chat/send.png" style="cursor:default;" value="Send" /&gt;
        &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>My div present in index.html.erb</p>
  
  <pre><code>      &lt;table border="0" width="100%" cellspacing="0" cellpadding="0"&gt;
          &lt;tbody&gt;&lt;tr&gt;
              &lt;td align="left" width="80%" valign="top" style=""&gt;
                &lt;%= text_area :chat, :chatContent,  :id=&gt; "chatContent_field", :cols=&gt;"100", :rows=&gt;"6" %&gt;
              &lt;/td&gt;
              &lt;td align="left" width="20%" valign="bottom" style="padding-left:10px;padding-left:10px;x" &gt;
                &lt;div id="chat_area"&gt;
                   &lt;%= render :partial =&gt; 'chat_area' %&gt;
                &lt;/div&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
  </code></pre>
  
  <p>Any help is appreciated.</p>
  
  <p>Regards,</p>
  
  <p>Salil Gaikwad</p>