We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

jSON returns html tags? JSON read problem

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

1
Contributor
1
Reply
3 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
Question
Answered
christos312
Light Poster
25 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Never mind solved

christos312
Light Poster
25 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Self-Answered as of 1 Year Ago

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0603 seconds using 2.68MB