Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:32:06+00:00 2026-05-27T20:32:06+00:00

Right now I can call a method using ajax (:remote=> ‘true’) at awisprotect_path by

  • 0

Right now I can call a method using ajax (:remote=> ‘true’) at awisprotect_path by simply clicking on the “x” in this link

<%= link_to "x", 
    awisprotect_path,
  :remote => true,
  :method => :post,
  %>

The controller action renders jquery so the response is included into the html in the view

<div class="awishanswer">

</div>

That’s all working fine. However, instead of having an “x” to click, I wanted the user to click a button and get the same result. So I essentially just wanted to put the link info

<%= link_to "x", 
    awisprotect_path,
  :remote => true,
  :method => :post,
  %> 

into this button

 <button class="btn small primary" >
                    check
</button>

So I created this form and put it in a partial

<%= form_tag(:controller => "sessions", :action => "awisprotect", :remote => true, :method => "post") do %>


 <button type="submit" class="btn small secondary">check awis</button>

 <% end %>

but the problem is that the controller action that renders js is not putting the result of the action into the html div. Instead, it’s redirecting to a blank page and then printing the jquery method with the result that I was checking for with the controller action. the blank page just shows this…

$('div.awishanswer').html(' html to be inserted in div');

Can anyone explain?

In the url it says

http://localhost:3000/awisprotect?method=post&remote=true
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:32:07+00:00Added an answer on May 27, 2026 at 8:32 pm

    in the view file

    <div class="awishanswer" id="awishanswer">
        <% form_remote_tag :url => {:controller => "sessions", :action => "awisprotect"}, 
                        :html => {:method => "post"}, :update => "awishanswer" do %>
            <input type="submit" class="btn small primary" value="check" />
        <% end %>
    </div>
    

    in the action

    def awisprotect
        @flag = params[:flag] // suppose sending parameter flag from form
       // do something
       render :partial => 'partial file containing html to send to view'
    end
    
    1. The form will be submitted when the submit button is clicked.
    2. the action will send the html contained in partial file.
    3. the form will update the div with id provided in form with the html code send back from action.

    EDIT:partial file

    <%if @flag%>
    // include some html
    <%else%>
    // include some other html
    <%end%>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I can use this URL to request a Google Static Maps image
How can I validate the user input by using scanf. Right now I have
I have this function, which is doing an asynchronous call to FB.api method. Now,
How do you install Boost on MacOS? Right now I can't find bjam for
Background: I have a kubuntu laptop right now that I can't use wirelessly, i.e.
I'm pretty much at wits end right about now and can't seem to figure
I can't seem to see the forest for the trees right now (Looked at
I'm learning Ruby right now and I got stuck, maybe you guys can help
How can i make sure that several divs are slided up? Right now I
Users on my site can post news items. But right now, it's all honor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.