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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:36:30+00:00 2026-05-26T23:36:30+00:00

While on a html page, I’m using an asynchronous XMLHttpRequest request in my Javascript

  • 0

While on a html page, I’m using an asynchronous XMLHttpRequest request in my Javascript to update a value in my database for a Ruby on Rails application. This update needs to happen “behind the scenes” without the user’s knowledge. Unfortunately, because there is no output html to this request (it is an asynchronous request), it’s very hard to debug why the database value is not updating.

In the initial html.erb file, the javascript is as follows:

function NAME() {
  var url = '/custom_path'; // this path points to the update method in my controller
  var request = new XMLHttpRequest();
  var params = null;

  request.open("POST",  url, true); // open asynchronous post request
  request.send(params);
}

I don’t actually pass any parameters because the only value that I need is stored in a cookie (you’ll see in the excerpt my code for the method). My Routes file includes the following line:

match'/customer_path', :to => 'activities#update' 

Finally, the code to my “update” method in the Activity table is as follows:

def update
  @dummy_var = Activity.find(cookies[:activity_id])
  @dummy_var.column_var = false
  render :layout => false
end

I’m trying to update the value of “column_var” in my Activity table for the row with the :id column specified by the cookie. Any ideas where I’m going wrong? I have confirmed that the Javascript function is being called and that cookies[:activity_id] has been set properly.

Thanks in advance!

  • 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-26T23:36:31+00:00Added an answer on May 26, 2026 at 11:36 pm

    I think the answer is pretty simple here, try calling save on the @dummy_var instance variable.

    To test this sort of thing out with ajax, you can use Rails.logger.debug, which accepts a string. You can then check the logs with debug outputs, see what happens. Also you can use something like firebug to see if the request responds with an error.

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

Sidebar

Related Questions

I have an HTML page with a JavaScript code that sends AJAX request. The
I am using this code to retreive a html page and parse it while(doc
I want to ask how can someone read keystrokes while in a html page
while using beautifulsoup to parse a table in html every other row starts with
hie i have a html form and while posting a request to a url
while ($row= mysql_fetch_array($result, MYSQL_ASSOC)) { $id=$row[id]; $html=<<<html <tr><td> <input style=float:left type=checkbox name=mycheckbox value=$id> <span
There are certain guide lines to be followed while writing Html for you page.
I have an html page with JavaScript code for setting the phone number format
I have the following code on an html page: <script type=text/javascript> <!-- window.location.replace(http://www.example.com/); -->
I am appending some html inside a table tag while performing each Ajax request.I

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.