Hello, I have a question, I am using the following jQuery code to get some data from a database

$('#CountryA1').keyup(function(){
        var country = $('#CountryA1').val();
        $.get('test.php',{name: country},function(data){
            
            
            
            $('#test').html(data);
            
            
            
        })
     });

Now, the <p> HTML tag with id test shows me these data

[{"id":"4","Description":"Bosnia-Hercegovina"},{"id":"9","Description":"Cyprus"},{"id":"10","Description":"Czech Republic"},{"id":"17","Description":"France"},{"id":"20","Description":"Greece"},{"id":"21","Description":"Croatia"},{"id":"25","Description":"Iceland"},{"id":"28","Description":"Liechtenstein"},{"id":"32","Description":"Monaco"},{"id":"34","Description":"Macedonia"},{"id":"49","Description":"Vatican City State"}]

But using Chrome Inspect plugin I see that PHP return this

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">

<html>
<head>
    <title></title>
</head>

<body>
</body>
</html>
[{"id":"4","Description":"Bosnia-Hercegovina"},{"id":"9","Description":"Cyprus"},{"id":"10","Description":"Czech Republic"},{"id":"17","Description":"France"},{"id":"20","Description":"Greece"},{"id":"21","Description":"Croatia"},{"id":"25","Description":"Iceland"},{"id":"28","Description":"Liechtenstein"},{"id":"32","Description":"Monaco"},{"id":"34","Description":"Macedonia"},{"id":"49","Description":"Vatican City State"}]

which includes some HTML tags. I tried to use $.parseJSON but (I suppose) because of the HTML tags the $.parseJSON does not work.

How can I get the data one-by-one from the JSON that PHP returns and populate them in a select input?

Thanks in advance

Never mind solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.