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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:07:09+00:00 2026-05-21T12:07:09+00:00

I’m trying to send a login request to rails Restful API from my Phonegap

  • 0

I’m trying to send a login request to rails Restful API from my Phonegap app on iOS.
Following code works with jQuery 1.5 but not with jQuery 1.4.2.

Does anyone know why this is the case?


$.ajax({
type: 'POST',
url: urlFactory.getLoginURL(),
data: { 'email': emailVal, 'password': passwordVal },
success: onSuccess,
error: onError,
dataType: "json"
});

The web server gives me the following error:


Started POST "/login.json" for 127.0.0.1 at Mon Apr 18 00:29:38 +0100 2011
Processing by SessionsController#create as JSON
Parameters: {"password"=>"[FILTERED]", "email"=>"example@gmail.com"}
User Load (0.3ms) SELECT users.* FROM users WHERE (users.id IS NULL) LIMIT 1
Completed in 251ms
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
app/controllers/application_controller.rb:37:in require_authorisation_happened'
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack- 3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.4ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack- 3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (14.1ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack- 3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (23.4ms)

It returns following in the successful case:


Started POST "/login.json" for 127.0.0.1 at Mon Apr 18 00:16:25 +0100 2011
Processing by SessionsController#create as JSON
Parameters: {"password"=>"[FILTERED]", "email"=>"example@gmail.com"}
User Load (0.3ms) SELECT
users.* FROMusersWHERE (users.idIS NULL) LIMIT 1
User Load (19.4ms) SELECT
users.* FROMusersWHERE (users.email= 'example@gmail.com') LIMIT 1
Completed 200 OK in 306ms (Views: 4.6ms | ActiveRecord: 19.7ms)

  • 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-21T12:07:10+00:00Added an answer on May 21, 2026 at 12:07 pm

    You are missing an authenticity token. In rails2 you can use form_authenticity_token in your view to render the authenticity token and then you’ll need to add that to the parameters submitted by the form.

    In Rails3 it’s easier. Just add <%= csrf_meta_tag %> in the head of your layout and then ensure you use the rails.js library for the ajax. This will pickup the authenticity token and submit it with the form.

    There is a short writeup here http://www.themodestrubyist.com/2010/02/24/rails-3-ujs-and-csrf-meta-tags/

    And an example app here https://github.com/grigio/rails3-ujs-demo.git

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.