Forum: Ruby on Rails ajax question about refreshing divs

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rodrigo D. (Guest)
on 2006-03-28 23:11
(Received via mailing list)
Ok, I have manny divs in the html, and I have a login form in a inner
div, if the user tries to login and the user/password is invalid, only
the inner div needs to be refreshed and show the user the error. If the
user/password is  ok, the main div needs to be refreshed.

How could I do this?

this is the view in example

<div id="MainDiv">


  <div id="InnerDiv">

    <%= form_tag :action => "login" %>

      <%= text_field "user", "username", "size" => "20", "class" =>
"Textos-02" %>

      <%= text_field "user", "password", "size" => "20", "class" =>
"Textos-02" %>

      <%= image_submit_tag "bot-ok.gif" %>

    <% end_form_tag %>



and this is the controller

class HomePageController < ApplicationController

  def login

    #More than 2 parameters means an post (there is always a post couse
it's ajax)

    if params.length == 2

            @user =


      if @user.username == "foo" && @user.password == "foo"

        logger.warn "loggin failed, refresh only InnerDiv and show the


        logger.warn "loggin failed, refresh MainDiv"



    #Show the page

    @headers["Content-Type"] = "text/html; charset=ISO8859-1"

    render :layout => false



Rodrigo D.

Iplan Networks                Datos Personales

removed_email_address@domain.invalid       removed_email_address@domain.invalid <> <>

5031-6303                     15-5695-6027
This topic is locked and can not be replied to.