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 8389957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:51:43+00:00 2026-06-09T18:51:43+00:00

I have table on with reports(amount, date). I want user to choose date using

  • 0

I have table on with reports(amount, date). I want user to choose date using datepickers and show reports, that are created between dates user’s chose.

So I need to pass these variables from AJAX form.

I added AJAX form. Here is my _form.html.erb:

<%= form_tag(:controller => "financial_reports", :action => 'report', :remote => true) do%>
  <span id="pickers">From</span> 
  <%= datepicker_input "report","start_date", :dateFormat => "dd/mm/yy" %>
  <span id="pickers2">To</span>
  <%= datepicker_input "report", "end_date", :dateFormat => "dd/mm/yy"%>
<%=  submit_tag "Run Report", :class => "btn super", :id => "btn "%>

And I have partial, which is showing report. |

_financial_report.erb.html

 <table class="table" id="performance_report">
  <thead>
  <th>Date</th>
<th>Amount</th>
<th>Currency</th>
  </thead>
 <% @financial_reports.each do |financial_report| %>
  <tr>
   <td> <%= financial_report.created_at.strftime("%d/%m/%Y")%></td> </td>
<td><%= financial_report.amount %></td>
<td><%= financial_report.currency %></td>
  </tr>
  <% end %>
    <tr>
  <td>Total</td>
  <td><%= current_user.financial_reports.sum(:amount)%></td>
  </tr>
     </table>

and I am rendering this partials on my index.erb.html

            <div id="report_form"><%= render 'form' %></div>
             <%= render 'financial_report' %>

In my report.js.erb I want to return apporpiate reports:

         $('.report').apppend('<%= escape_javascript(render(@financial_report)) %>');

Here are my controllers(I don’t know where I should call “where” condition

       def index
          @financial_reports = current_user.financial_reports#.where(:created_at => the_start.to_date..the_end.to_date)
       ...
     end

or here

  def report
    @financial_reports = current_user.financial_reports#.where(:created_at => the_start.to_date..the_end.to_date)//here
     respond_to do |format|
    format.js
   end
  end

Here are my HTML of report form:

     <form accept-charset="UTF-8" action="/financial_reports/report?remote=true" method="post">
     <input id="report_start_date" name="report[start_date]" size="30" type="text" class="hasDatepicker">
      <input id="report_end_date" name="report[end_date]" size="30" type="text" class="hasDatepicker">

and in my routes:

        match 'financial_reports/report' => 'financial_reports#report'

I can get variables using AJAX:

  $.ajax({ 
  type: 'POST', 
  url: 'financial_reports/report', 
  data: {'start_date' : $("input[name='report[start_date]']").val(), 
    'end_date' : $("input[name='report[end_date]']").val() }, 
  success: function(data){
 //data is whatever you RETURN from your controller. 

    } 
 }); 

How should I solve this problem ? Maybe, I missunderstand AJAX stuff ?

P.S. When I’m calling report action it shows me blank page.

  • 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-06-09T18:51:44+00:00Added an answer on June 9, 2026 at 6:51 pm

    You say you are able to get a response from the ajax .
    But are you returning anything from the action ?
    If the ajax request when fired explicitly works fine , that means your routes are fine . But the ajax request should trigger the javascript you have in report.js.erb .
    If that doesn’t happen , I suspect parameters to be in the wrong format . I can see that in the ajax request you are passing :

      data: {'start_date' : $("input[name='report[start_date]']").val(), 
        'end_date' : $("input[name='report[end_date]']").val() } 
    

    This is fine if the action is expecting params[:start_date] and params[:end_date] . But the form does not send the params in that format .

    My suggestion :
    With firebug or some other debugging tool , ensure it’s a POST request , and the parameters should be in the expected format . Inspect the response of the request to see the return value . It should be a “success” response . Also check that the method “report” in the controller is a public method .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing reports and the date/time they were created. I'd like
I have table like this: +----+---------+---------+--------+ | id | value_x | created | amount
I have an entity defined as follows @Entity(name = Report) @Table(name = REPORTS) @org.hibernate.annotations.Entity(dynamicInsert
I have data in 2 tables, and I want to create a report. Table
I have table with around 70 000 rows. There is 6000 rows that i
I have a table that contains a history of costs by location. These are
I have a table in MySQL with multiple of reported events (primary key, date
I have a table that looks like this: ------------------------------------------------------------------- CUSTNUM (INT), ITEMNUM (INT), MONTH
I have a table I am trying to generate reports from. Its basically a
I have an invoice table. When I change a total amount to be paid,

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.