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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:51:05+00:00 2026-06-08T03:51:05+00:00

I have some javascript that displays some data from my database on my webpage.

  • 0

I have some javascript that displays some data from my database on my webpage. I also have a button that when the user clicks it some logic occurs in the controllers and then I want to have the data displayed changed. However, at the momment when they click the button nothing happens (page is not reloaded). Could you guys help me set that up? Here is what I have so far:

controller:

class QtlsController < ApplicationController
 require 'json'
 require 'uri'
 $rollback = nil
 def index
   logger.debug "\nrollback is: #{$rollback}\n"
   render "index"
 end
 def rollback
   $rollback = params[:version].gsub(/"/,'')
   redirect_to :action => :index
 end
end

view:

  <%- if $rollback.nil? %>
     generates one type of table
  <%- else %>
     generates another type of table
  <%- end %>
  ...some other logic and buttons etc...
  jQuery(function() {
            jQuery( "#rollback").button();
            jQuery( "#rollback").click(function() {
                    var version = getSelectedText('version_selector');
                    jQuery.ajax({
                            type: "POST",
                            headers: {
                                    'X-Transaction': 'POST Example',
                                    'X-CSRF-Token': jQuery('meta[name="csrftoken"]').attr('content')
                            },
                            url: "/qtls/rollback",
                            data: {version: JSON.stringify(version) },
                            dataType: 'json',
                            sucess: function() { alert("Success! Rollbacked"); }
                    });
            });

Here is what is in log files when I go to the page and when I click the rollback button:

 Started GET "/qtls" for 10.64.229.59 at Tue Jul 17 16:48:52 -0500 2012
 Processing by QtlsController#index as HTML
 rollback is: 
 ROLLBACK IS NIL!!!
   Qtl Load (2.0ms)  SELECT `qtls`.* FROM `qtls` 
   Rendered qtls/index.html.erb within layouts/application (404.8ms)
   Rendered shared/_user_nav.html.erb (1.3ms)
   Rendered shared/_nav.html.erb (1.3ms)
   Rendered shared/_footer.html.erb (0.6ms)
 Completed 200 OK in 544ms (Views: 540.9ms | ActiveRecord: 2.0ms)
 Started POST "/qtls/rollback" for 10.64.229.59 at Tue Jul 17 16:48:57 -0500 2012
 Processing by QtlsController#rollback as JSON
   Parameters: {"version"=>"\"test1\""}
 Redirected to http://10.10.136.244:4000/qtls
 Completed 302 Found in 3ms (ActiveRecord: 0.0ms)
 Started GET "/qtls" for 10.64.229.59 at Tue Jul 17 16:48:58 -0500 2012
 Processing by QtlsController#index as JSON
 rollback is: test1
   Rendered qtls/index.html.erb within layouts/application (37.7ms)
   Rendered shared/_user_nav.html.erb (3.3ms)
   Rendered shared/_nav.html.erb (4.3ms)
   Rendered shared/_footer.html.erb (2.0ms)
 Completed 200 OK in 99ms (Views: 97.4ms | ActiveRecord: 0.0ms)
  • 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-08T03:51:06+00:00Added an answer on June 8, 2026 at 3:51 am

    it’s a reaaaaaally bad style to use global variables like $rollback!

    if you want to store user-data use your session-object.

    use the jquery-rails gem to integrate with jQuery in your views and then use the :remote => :true in your form, so that rails can handle the form-submission.

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

Sidebar

Related Questions

I have some html which displays data from my database. Shown below is a
I have a form field that uses some Javascript to format user input 'price'
I have a php page that pulls data from a mysql database based on
I have Jquery+Ajax page that connects to server gets some data, and displays it.
I have a page that displays data from an object. I'm loading the object
I have some javascript that I am using for some audio on my website:
I have some javascript that goes out and fetches a javascript class on another
I have some JavaScript that I'm trying to benchmark the time it takes to
Here is the situation. I have some javascript that looks like this: function onSubmit()
I have some Javascript code that will programmatically register an COM interop assembly by

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.