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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:47:03+00:00 2026-06-07T01:47:03+00:00

I’m trying to keep the user on the same page and execute some Javascript

  • 0

I’m trying to keep the user on the same page and execute some Javascript after an Update is performed..

However my js.erb never seems to get called and instead I get redirected to the route “http://localhost:3000/upload_images/id” and my firebug console produces…

"NetworkError: 406 Not Acceptable -http://localhost:3000/upload_images/id"

Update Action

    def update  
    @upload_image = UploadImage.find(params[:id])
    #If this image is set as the preview restore all associated images to default
    if params[:upload_image][:preview] == "1"
      other_uploads = @upload_image.upload.upload_images.where("not upload_images.id = ?", @upload_image.id)
      other_uploads.each do |upload_image|
        upload_image.preview = "0"
        upload_image.save
      end
    end      
    respond_to do |format|    
      if @upload_image.update_attributes(params[:upload_image])
        #keep the user on current page and call some Javascript
        format.js{render :template => 'update.js.erb'}
      else
        format.html { render action: "edit" }
        format.json { render json: @upload_image.errors, status: :unprocessable_entity }
        format.js
      end
    end
  end

Update.js.erb

alert("hello world!");

Edit form

<%=form_for(@upload_image) do |f| %>
   ....
<% end %>

It’s not important for me to see the live updates, I don’t mind if the user has to refresh to see them. I just want to keep the page state as is (with the exception of some changes made by JQuery) and make a post to the database.

  • 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-07T01:47:04+00:00Added an answer on June 7, 2026 at 1:47 am

    You probably need to switch to a remote form:

    <%= form_for(@upload_image, :remote => true) do |f| %>
    

    Otherwise your form will attempt an HTTP POST that expects an HTTP response.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.