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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:31:24+00:00 2026-05-16T00:31:24+00:00

As the title may suggest, I have been using jQuery AJAX to try and

  • 0

As the title may suggest, I have been using jQuery AJAX to try and pull a list of Cities from a database when a Province is selected.

I am using the following code:

$('#province').change(function()
{
    var province = $(this).val();

    /*$.get("<?php echo site_url('cottage/cities'); ?>?province="+province, function(data) 
    {
        console.log(data);
        for (i=0;i<=data.length;i++)
        {
            //$('#citydiv').append(data['city']+'<br/>');
            //$('#city').append('<option value="'+data[i]['city']+'">'+data[i]['city']+'</option>');
        }
    }); */
    $.ajax({
    url: "<?php echo site_url('cottage/cities'); ?>?province="+province,
    method: 'GET',
    dataType: 'json',
    success: onDataReceived
    }); 
    function onDataReceived(series) 
{
    console.log(series);

}   
});

And I also have a Province and City drop down associated with them.
The problem is that I keep getting “undefined” returned, as it doesn’t like the way my data is sent.

The data looks like:

[{"city_id":"1107","city":"Young's Point","province":"Ontario","lat":"44.490345","lon":"-78.236008"},{"city_id":"1108","city":"Zurich","province":"Ontario","lat":"43.421185","lon":"-81.624832"}]

Any help would be greatly appreciated!

  • 1 1 Answer
  • 1 View
  • 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-16T00:31:25+00:00Added an answer on May 16, 2026 at 12:31 am

    json encoded strings look like this

    {"a":1,"b":2,"c":3,"d":4,"e":5}
    

    whereas you have square brackets
    try encoding your data in php with json_encode($array);

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

Sidebar

Related Questions

The title may have been confusing, but please let me explain: Currently when I
Okay that title may not have been too clear, I am building a site
The title may be confusing so ill try to elaborate. I have a business
Ok so my question title may have been a little confusing. Here's my example:
Sorry the title may not be very clear. Basically I have a wrapper for
I'm using ajax to retrieve some data from the backend. I get the result
This title may seem strange, so let me try to explain what I'm trying
The title may be a bit confusing, so let me explain. I have a
My title may make my question sound confusing, but it is not. I have
this title may not best describe my problem. I'm using Netbean GUI builder to

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.