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

  • Home
  • SEARCH
  • 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 5957511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:24:38+00:00 2026-05-22T18:24:38+00:00

$.ajax({ url: /rooms.json, dataType: json, data: { q: req.term }, success: function (data) {

  • 0
$.ajax({
    url: "/rooms.json",
    dataType: "json",
    data: {
        q: req.term
    },
    success: function (data) {
        alert('test');
        responseFn($.map(data.room, function (item) {
            alert('test1')
            return {
                label: item.title
                value: item.title
            }
        }));
    }
});

data from /rooms.json?q=a looks like below:

[{
    "room": {
        "created_at": "2011-05-19T18:08:04Z",
        "title": "Great Office Space for Rent!",
        "cost": 450,
        "updated_at": "2011-05-19T18:08:04Z",
        "property_id": 4,
        "maximum_capacity": 234,
        "id": 15,
        "fulladdress": "550 12th St NW, Washington D.C., DC 20005, USA",
        "user_id": null,
        "phone": "301-395-7578",
        "description": "Great office space to rent in DC\r\n\r\nPlease contact. ",
        "email": "something@gmail.com"
    }
}]

In the above code, I see the first alert but not the second alert so something is going wrong in the handling of the data from the json request.

What should I do to fix this?

Update
After playing around w/ some code I figured it out.

I had to tweak the rails controller to render json as below

format.json {render :json => @events.map(&:attributes)}

Furthermore, for jQuery code I had to remove .room from the code below

responseFn($.map(data.room, function (item) {
  • 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-22T18:24:39+00:00Added an answer on May 22, 2026 at 6:24 pm

    silly me

    in rails code:

    format.json {render :json => @days.map(&:attributes)}
    

    in jQuery code

    responseFn( $.map( data, function( item ) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code: $.ajax({ url: 'http://tinysong.com/b/Beethoven?format=json&key=<my key..>', dataType: 'jsonp', success: function(response) { console.log(response); } });
$.ajax({ url: '/create_lead', data: { name: $('#lead_gen_name').val(), lead_gen[email]: $('#lead_gen_email').val(), }, type: 'POST', dataType: 'json',
function ajaxRefresh(actionUrl) { $.ajax({ url: actionUrl, success: function() { return true; }}); return false;
$.ajax({ url : baseUrl, data : { query : query, num : tracksRequested },
$.ajax({ url: http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&format=json&api_key=708f179518b2093d23f0aef284b565a4&photo_id=6115633659&jsoncallback=?, type: GET, cache: true, dataType:'jsonp', success: function (data) { var largeSRC
I'm trying to use the new room feature in Socket.io v.7 to create dynamic
I have a small ajax jquery script which returns some XML for me. Whilst
Using MVC3 I am trying to accomplish the following. I have a table which
I have a long polling request on my page. The script on the server
Im using the jQuery GetJSON call in my asp page. Its something like this..

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.