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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:20:01+00:00 2026-05-30T19:20:01+00:00

My goal is to allow for non logged in users to view a page

  • 0

My goal is to allow for non logged in users to view a page with a bookmark button. When non logged in user clicks on the bookmark button, he should be presented a login form in a modal, submit their credentials and have the bookmark added (same way Yelp does it).

My problem is I can’t make the login form post the create bookmark request.

Here is my jQuery code.

    $("form#login-form").submit(function(event) {
        event.preventDefault();

        $.post('/account/authenticate_xhr', $(this).serialize(), function(data, textStatus, jqXHR) {
console.log("posted authenticate");

            if (data['user_id']) {
                // log in successful
console.log("logged in!"+data['user_id']);
                if (data['next_action']) {
                    // prepare and post next action
console.log('next action!');
                    var next_action = data['next_action'];
                    var controller = next_action['controller'];
                    var action = next_action['action'];
                    var data = next_action['data'];

                    $j.post('/' + controller + '/' + action, { data: data }, function(data, textStatus, jqXHR) {
                    }, "script");
                }
            };
        }, "script");

console.log('ending');

    });

When I run it, ONLY “ending” shows up in the console. I can’t execute the code inside the authenticate_xhr post request while it seems the request is executed properly on the back end. But the response authenticate_xhr show me the right JSON object…

What am I missing here?

UPDATES:

  1. I followed charlietfl suggestion and replaced ‘script’ with ‘json’ to call ‘/account/authenticate_xhr’ and now get the first post working fine. I now need to execute my js.erb response…
  2. Kept ‘script’ for the second post request and added escape_javascript in the js.erb view
  • 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-30T19:20:02+00:00Added an answer on May 30, 2026 at 7:20 pm

    You set the dataType as script…needs to be json. Even if request is for jsonp that gets wrapped in a function, you still request json

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

Sidebar

Related Questions

My ultimate goal is to allow users to select a file from a dialog
My goal is to create an entry form (addnew.php) that will allow me to
Goal: Once i click on the start button on my user interface, i currently
Goal: allow end users to write jython scripts that will create AI objects [for
Goal: Allow user to select one or more images from his photo library. Get
The goal: Allow user to turn on and off different layers of data; and
Goal: Allow a user to authentication with Facebook into an iOS application which requires
My goal is to create a form that display multiple checkboxes and allows users
Right now I have two activities. My goal is to allow the user to
Goal: I'd like to allow users to create questions and collect information from other

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.