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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:23:01+00:00 2026-06-10T01:23:01+00:00

Here is my code that I’m including when I load the page: <script type=text/javascript>

  • 0

Here is my code that I’m including when I load the page:

<script type="text/javascript">
function test() {
    $.get('/login', function(data){
        alert("test");
        $('#flash_content').html("hi");
        }, 'script');}

    function test2(){
    var jqxhr = $.get("/login", function(data) {
            $('#flash_content').html(data);}, 'script')
            .success(function() { alert("second success"); })
            .error(function(request, status,error) { alert(error); })
            .complete(function() { alert("complete"); });}

    $(document).ready(function() {
    $("#login").click(function(event){
     event.preventDefault(); // Prevent link from following its href
    test2();
    });});
    </script>

When I call test2(), I can see in my rails server log that it renders the views that it should, and in firebug I see my response from the ajax get is indeed the form I want to overwrite onto the page, however nothing on the page actually changes. I’ve replaced “Data” with the string “hi” and that indeed gets put into the page. As you can see, an alert pops up and tells me :

SyntaxError: missing ; before statement

Here is my controller method for signing in:

@user = User.new
respond_to do |format|
    format.html { }
    format.js  {render :layout => false }
    format.xml  { head :ok }
  end

and the view that should be rendered:

    <%= form_tag user_sessions_path, :method => :post do  %>
  <div class="field">
    <%= label_tag :username %><br />
    <%= text_field_tag :username %>
  </div>
  <div class="field">
    <%= label_tag :password %><br />
    <%= password_field_tag :password %></br>
    Remember me : <%= check_box_tag :remember %>
  </div>

  <div class="actions">
    <%= submit_tag "Login" %>
  </div>
<% end %>

I’ve been at this for hours, so maybe I’m not seeing something obvious 🙁 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-10T01:23:03+00:00Added an answer on June 10, 2026 at 1:23 am

    You’re telling jquery that what’s being returned is javascript (last parameter to $.get). This tells jquery that when it gets your response it should evaluate it.

    However your response is html – trying to evaluate that as javascript doesn’t make sense. You should either be omitting that parameter (letting jquery guess) or set it to ‘html’.

    Rails will still use the format.js block for an xhr request, although I believe you’ll need to put it before the format.html version.

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

Sidebar

Related Questions

here is code that I have: agent = Mechanize.new page = agent.get 'http://google.com' page.save
I cannot get this to work, here is code that I found in another
Here is my Code that I'm trying to run on Mac OS X: import
Here is the code that doesn't work: Enemy.strength = srand((unsigned)time(NULL)) % 10; Enemy.strength is
Here is my code that adds a line to the grid by pressing the
Here is the code that cause me problem since few hours: TabItem newTab =
Here's my code that is not working: print To: ; my $to=<>; chomp $to;
Here is my code that fails: bool Table::win(const Card &card) { for (int i
Here is the code that I have for my cell of my UITableView: forKeys:[NSArray
I have some code here that uses bitsets to store many 1 bit values

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.