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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:20:02+00:00 2026-05-21T02:20:02+00:00

I am trying to perform a very simple getJson() request but no matter what

  • 0

I am trying to perform a very simple getJson() request but no matter what I change I am getting parseerror from jQuery.

I am using ROR 3.01, Mongoid2.0, jQuery 1.5.2

The Controller Sending the json

    class SuggestController < ApplicationController

      def states
          states = States.only(:name, :state_id).where(:country_code => params[:country])
          render :json => states.entries
      end

    end

Jquery to handle the response.

    $("#property_country").change(function(){

        $.getJSON("/suggest/states",{country: $(this).val(), ajax: 'true'}, function(j){
        var options = '';
        for (var i = 0; i < j.length; i++) {
          options += '<option value="' + j[i].state_id + '">' + j[i].name + '</option>';
        }
        $("select#property_state").html(options);
      });

    });

  $.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {   
        alert(textStatus);
        alert(errorThrown);
        alert(XMLHttpRequest.responseText);
  }});

And example of the json response

[{"_id":"4d925dbe4aa6936d4f0cdefe","name":"Devon","state_id":1},{"_id":"4d925dbe4aa6936d4f0cdeff","name":"Berwickshire","state_id":2}]

I cant seem to find out why im getting parseerror and what it actually means.

Hope you can advise.

  • 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-21T02:20:03+00:00Added an answer on May 21, 2026 at 2:20 am

    Ok I finally worked it out.

    Basically because render => :json already created the objects all I need to do was do a normal get request and then just loop my data.

    Hope this helps someone in the future.

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

Sidebar

Related Questions

Trying to perform a very simple task here. I have an <ol> that contains
I am trying to perform a very simple task which is Add the user
I'm trying to perform a POST request with node.js, but it always seems to
I'm trying to perform a simple LINQ query on the Columns property of a
I'm trying to perform a simple INSERT and return the identity (auto-incrementing primary key).
I am trying to perform some unit testing on the iphone but for some
In this situation I am trying to perform a data import from an XML
I'm a newbie to WCF, trying to perform relatively simple task. I'm trying to
I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using
I'm trying create a ASMX webservice that can perform a HTTP GET request. I

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.