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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:06:04+00:00 2026-05-26T02:06:04+00:00

In rails application, i am trying to fetch few records using a Ajax/jQuery, am

  • 0

In rails application, i am trying to fetch few records using a Ajax/jQuery, am getting the right data but the problem how do i parse the returned data and render it as HTML?

my js function

 $.ajax({
        url: "/questions/retrieve_function",
        dataType:'json',
        data: {
            'obsolete': 1
    },
    success: function(data){
        $.each(data, function(key, value) {
            alert(key + ", " + $.param(value));
        });

    },
    error: function(){
        alert('error');
    },
    type: 'GET'
});

my controller method:

def retrieve_function
 obsolete = params[:obsolete]
 @values = values.find(:all, :conditions => ["obsolete = ?", obsolete])
  respond_to do |format|
   format.html
   format.json { render :json => @values }
  end
end

am using $.param currently to check whether am getting correct values, any help would be appreciated thanks 🙂

Update

The format returned

"[[
  {\"question\":{\"created_at\":\"2011-09-26T12:56:41Z\",\"choicea\":\"dg<br>\",\"qtype\":\"multiple\",\"title\":\"dfgdfg<br>\",\"choiceb\":\"dg<br>\",\"updated_at\":\"2011-10-10T14:41:52Z\",\"choicec\":\"dfg<br>\",\"choiced\":\"dg<br>\",\"id\":50,\"hint\":\"dg<br>\",\"obsolete\":1,\"correctans\":\"C\"}}

]]"
  • 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-26T02:06:04+00:00Added an answer on May 26, 2026 at 2:06 am

    First there should be just one bracket in your json format you have to change your server code like that. And then u can use this function to get your values from json

    $.each(data,function(key,value){
        alert(key+" - "+value.question.title + " - "+value.question.created_at+" ...")
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run a Rails application, but I am getting the following
I'm trying to send data to my Ruby on Rails application via an AJAX
I'm trying to make an API for my rails application using JSON responses to
I'm trying to display images using my web application written in Rails. I've come
I am trying to create a chat application on heroku using the following https://github.com/tarnfeld/PusherChat-Rails
In my rails application I am trying to access pagination via an ajax call.
In my rails application I am trying to use rails3-jquery-autocomplete gem. I included the
In my Rails application I am trying to use the acts_as_taggable_on_steroids plugin but it
I am trying to get my rails application running on my web server, but
I'm trying to deploy my rails application by using Passenger and Capistrano on Dreamhost.

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.