1,105,399 Community Members

jSON returns html tags? JSON read problem

Member Avatar
christos312
Light Poster
25 posts since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
christos312
Light Poster
25 posts since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Never mind solved

Question Self-Answered as of 2 Years Ago
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article