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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:50:46+00:00 2026-05-22T16:50:46+00:00

I’m trying to replace the content of a div after clicking on a link

  • 0

I’m trying to replace the content of a div after clicking on a link using Rails 3, remote_link :remote => true and jQuery.

So far, I’ve been able to get the controller render the correct partial while responding with a 200 HTTP code. I’ve set some callbacks to find the origin of the problem:

jQuery(function($) {
    $("#follow-link").bind("ajax:before", function() {
        console.log("ajax:before");
    });

    $("#follow-link").bind("ajax:success", function(data, status, xhr) {
        console.log("ajax:success");
    });

    $("#follow-link").bind("ajax:complete", function() {
        console.log("ajax:complete");
    });

    $("#follow-link").bind("ajax:error", function(xhr, status, error) {
        console.log("ajax:error");
        console.log(error);
    });
});

While before and complete are triggered, success is not and error outputs “parsererror”. The content I get when I inspect the response in Safari’s developers tools is a simple string.

Why would it raise a parsererror? How can I get more information about what’s causing this error?

  • 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-22T16:50:46+00:00Added an answer on May 22, 2026 at 4:50 pm

    I’m going to propose an answer because comments don’t allow for any formatting. Here is is: Something is happening on the server side and jQuery is not getting what you think it is. Here’s an excerpt from the jQuery documentation:

    error(jqXHR, textStatus,
    errorThrown)Function A function to be
    called if the request fails. The
    function receives three arguments: The
    jqXHR (in jQuery 1.4.x,
    XMLHttpRequest) object, a string
    describing the type of error that
    occurred and an optional exception
    object, if one occurred. Possible
    values for the second argument
    (besides null) are “timeout”, “error”,
    “abort”, and “parsererror”. When an
    HTTP error occurs, errorThrown
    receives the textual portion of the
    HTTP status, such as “Not Found” or
    “Internal Server Error.”

    That implies that your controller may be responding with something other than the expected data. In that controller, try:

    Rails.logger.debug render_to_string(:partial => "followings/follow")
    

    In any case, check your logs to make sure what you think is happening really is happening. Also, write a test to verify this:

    # controller spec... modify if using Test::Unit
    it "sends cool javascript" do
      xhr.post :unfollow, :id => 83, :data-method => "delete"
      response.body should == "some known response"
    end
    

    Ok, it’s a hacky, brittle spec, but it will do until you know where things are going wrong.

    Once you get this working, everything else will fall neatly into place.

    • 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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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’Everest What PHP function

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.