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 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 using this simple script to generate images from text: <?php header('Content-type:
I have a PHP page with various forms I've been using jQuery to submit/verify
I have a news feed that has been developed using PHP, MySQL, and jQuery.
I have been using this script for a while and suddenly it just stopped
I am new to using ajax but have been using PHP for awhile. I
I have been using this script to send emails to certain staff but because
I have been using this code to implement a Popup JDialog of sorts, like
I have been using this code, but have been running into some memory issues:
I have been using this link to learn about multiprocessing, but I'm stuck on
I have been using this code with great success to pull out the first

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.