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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:53:40+00:00 2026-06-12T14:53:40+00:00

I have a select menu being populated by an Ajax call to a php

  • 0

I have a select menu being populated by an Ajax call to a php script that returns the list of products from a table in XML form.

The product table has about 400 records and for some reason, the select menu displays nothing with a select statement that returns all. Troubleshooting with Firebug, I can see the php code is successfully returning ALL 400 records correctly to the browser but it does not get displayed.

When I alter the select statement to be “SELECT ProductID,ProductName FROM product WHERE ProductID < 74”, it works, displaying the first 73 items. Thinking this could possibly be due to something wrong with item 74, I altered the where clause to “> 74″ but this also returned nothing. A where clause of ” > 74 and < 120″ however works.

What could possibly be the cause? Please find the code snippets below.

The javascript of the code is as follows:

function populateProducts(xmlindata) {

var mySelect = $('#ili_product');
 $(xmlindata).find("Product").each(function()
  {
    optionValue=$(this).find("id").text();
    optionText = $(this).find("name").text();
    mySelect.append($('<option></option>').val(optionValue).html(optionText));    
  });
}

The php code is:

<?php

include("dbconfig.inc.php");

header("Content-type: text/xml");
echo "<?xml version=\"1.0\" ?>\n";
echo "<products>\n";
$select = "SELECT ProductID,ProductName FROM product";
try {
    foreach($dbh->query($select) as $row) {
        echo "<Product>\n\t<id>".$row['ProductID']."</id>\n\t<name>".$row['ProductName']."</name>\n</Product>\n";
    }
}
catch(PDOException $e) {
    echo $e->getMessage();
    die();
}

echo "</products>";
?>
  • 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-06-12T14:53:41+00:00Added an answer on June 12, 2026 at 2:53 pm

    It would be a good practice to escape quotes and other characters while generating/forming html based on xml/json data

    In your case,

    optionValue=$(this).find("id").text().replace('\'','&quot;');

    or replace("'", "&rsquo;");

    This way you escape quotes, if they are the ones causing the problem. Not sure if the problem is due to breaking of the strings.

    you can escape multiple characters like this.

    .replace(/&/g, "&amp;").replace(/'/g, "&quot;");

    Notice // Regex and the g flag, this will find the characters globally.

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

Sidebar

Related Questions

I have a SELECT LIST MENU containing products and on this menu i use
I have a html select list menu,when user select an option he/she is redirected
I have a select that I'd like to use the custom menu display (rather
I have a little dropdown menu similar <select> , which contolled from external js-function.
I'd like to have a menu (select box replacement dropdown) that, when clicked, fades
I have a nested form that has a select dropdown menu. How can I
Say I have a form_for with a select menu to assign a User on
I have a simple HTML Form with one column having a select menu with
I have a simple dropdown menu: <form class=feedmenu align=center> <select onchange=showRSS1(this.value)> <option value=>Select an
I have some code that first selects an option value in a dropdown menu

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.