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

  • Home
  • SEARCH
  • 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 7988295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:24:01+00:00 2026-06-04T12:24:01+00:00

This might be a beginner question (I’m new to Rails 3), but I’m trying

  • 0

This might be a beginner question (I’m new to Rails 3), but I’m trying to use Ajax once a user clicks on a link, initiate a $.post call, and do some changes in the server-side.

In the _share partial, I have:

%a.fbbutton.twitterbutton{:id => "twitter"}       (href="javascript:window.open(%22http://twitter.com/share?text=Does anyone know a #{@branch.title} @branchly%21&url=http%3A%2F%2Fwww.branch.ly/branches/#{@branch.id}%22,%22Share%22,%22width=500,height=250,scrollbars=yes%22)" class="twitter button" onclick="submitWithAjax();") Tweet

The function SubmitwithAjax() is in application.js file:

function submitWithAjax() {
$.post('background_forward', $(this).serialize(), null, "script");  
     return false; }

In my routes I have:

match 'background_forward', :to => "branches#background_forward"

I just need to have the submitwithAjax function go to a specific method in my server. Would appreciate some help. Thanks!

  • 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-04T12:24:03+00:00Added an answer on June 4, 2026 at 12:24 pm

    Your js is fine so far, now you just need to add the correct action on the BranchesController that responds to a POST, as well as registering that method in your routes.rb (I believe it’s a GET by default).

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

Sidebar

Related Questions

This might be a silly question, but I'm a beginner in C#, so please
Okay, this might be a very silly beginner question, but: I've got an ClassA,
This might be an overly simple question, but I am a beginner at programming
im new to rails so this is a beginner question. I want to make
This might sound very very basic 101 type question, but I really need help
This might be a very simple question but i am unable to get it.
This might seem like a silly question, but after asking some questions on stackoverflow
I know this is a beginner's question, but I've been searching online and all
I'm a beginner in Android development but not in programming itself. Anyway, this question
I am a total beginner in both simulations so this question might be silly.

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.