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 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

Could someone tell me if this: $.ajax({ url: 'test.html', success: function(data) { alert(Data Loaded:
I do an ajax call: $.ajax({ url: '/foo/getData', dataType: 'json', async: false, success: function(data){
$('#post_form').submit(function() { $(#ajax_bar_loader).show(); $.ajax({ url: 'add.html', data: $('#post_form').serialize(), dataType: 'json', type: 'post', success: function(
$.ajax({ url: plugin.js, dataType: 'script', cache: true, success: function() { alert('loaded'); }}); 1) I
jQuery.ajax( { url:'http://en.wikipedia.org/wiki/Football', type:'get', dataType:'jsonp', success:function(data){alert(data);}, } i want to read wikipedia page from
I have this JSON Ajax function $.ajax({ url: ?page= + page, dataType: json, success:
$.ajax seems to be broken for me: $.ajax({url:'getGalleries.php', datatype:'jsonp', success: function(data){ $('#galleries').html(''); $.each(data,function(key,value) {
I have this: $.ajax({ url: blah.php?something, dataType: json .... success: function(x){ for(i in x.artists)
My code: $.ajax({ url: 'http://tinysong.com/b/Beethoven?format=json&key=<my key..>', dataType: 'jsonp', success: function(response) { console.log(response); } });
If I have a ajax call: $.ajax({ url: url, dataType: 'json', data: data, success:

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.