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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:28:57+00:00 2026-05-20T17:28:57+00:00

I have been using this PHP script for a long time and this is

  • 0

I have been using this PHP script for a long time and this is returning data to my getJSON . I changed to jquery new version v1.5.1 from 1.2.3 Today and giving parse error

  <?php

error_reporting(E_ALL);
ini_set("display_errors", 0);
include("conndb.php");

    function createoptions($table , $id , $field , $condition_field , $value)
    {
        $sql = sprintf("select * from $table WHERE $condition_field=%d ORDER BY $field" , $value);
        $res = mysql_query($sql) or die(mysql_error());
        if (mysql_num_rows($res) > 0) {
            while ($a = mysql_fetch_assoc($res))
            $out[] = "{optionValue: {$a[$id]}, optionDisplay: '$a[$field]'}";
            return "[" . implode("," , $out) . "]";
        } else

            return "[{optionValue: -1 , optionDisplay: 'No result'}]";
    }

    if (isset($_GET['country'])) {
        echo createoptions("state" , "state_id" , "state" , "country_id" , $_GET['country']);
    }


    if (isset($_GET['state'])) {
        echo createoptions("city" , "city_id" , "city" , "state_id" , $_GET['state']);
    }

    die();
    ?>

My getJson code

$.getJSON("select_old.php",{country: '$(this).val()', ajax: 'true'}, function(j){
                  var options = '';
                  for (var i = 0; i < j.length; i++) {
                    options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
                    if( i==0){
                     populateCity(j[i].optionValue );
                    }
                  }
                  $("select#state").html(options);
                }).error(function(xhr, ajaxOptions, thrownError) {  alert(xhr.statusText); })

Thanks for your help

Regards

Kiran

  • 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-20T17:28:57+00:00Added an answer on May 20, 2026 at 5:28 pm
    {country: '$(this).val()', ajax: 'true'}
    

    This should probably be

    var country = $(this).val();
    
    $.getJSON("select_old.php", { country: country, ajax: 'true' }, function(j) {
    

    Edit: Also, see my comment above regarding json_encode() – example

    $data = array();
    while ($a = mysql_fetch_assoc($res)) {
        $data[] = array(
            'optionValue'   => $a[$id],
            'optionDisplay' => $a[$field]
        );
    }
    return json_encode($data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing and testing with inline jQuery. I am using CodeIgniter and
I am using a PHP script using dns_get_record (with DNS_ANY) and it is working
I'm having a really difficult time understanding how this all works together. I've fiddled
Possible Duplicate: Can anybody suggest the best image resize script in php? I'm still
This is my first post and I have the feeling that this is something
Forgive me if this is a stupid question; it's been many years since I've
My form has several <p> elements which are added dynamically. This is how one
I am producing a script that others will put in their websites. It is
The weirdest thing is happening to me... I have a form I'm sending via
I just wanted a more elegant automated solution to my form validation. On PHP.net

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.