Need help with AJAX partial not refreshing browser asking to save .js instead

Hi, when i use the updatepassword action, it does not refresh the ajax
partial but forces the browser to save a file
why does that happen?

def updatepassword
      @user = current_user
  return unless request.post?
    if User.authenticate(current_user.login, params[:old_password])
      if ((params[:password] == params[:password_confirmation]) && !
params[:password_confirmation].blank?)
        current_user.password_confirmation =
params[:password_confirmation]
        current_user.password = params[:password]
    if current_user.save
          flash[:notice] = "Password successfully updated."
          redirect_to login_path #profile_url(current_user.login)
        else
                    flash[:error] = "An error occured, your password was
not changed."
      respond_to do |format|
      format.js
      end
        end
      else
                  flash[:error] = "New password does not match the
password confirmation."
        @old_password = params[:old_password]
      respond_to do |format|
      format.js
      end
      end
    else
      flash[:error] = "Your old password is incorrect."
      respond_to do |format|
      format.js
      end
    end
  end

never mind i solved it