如何打印xmlhttp响应?

I am getting some information from database, this information is getting back into JSON format now I need to print this JSON information. But my code is not working getCountryDetails.php is php file for interacting with the database. Following code is the script, When I click the button It intersects with database.

<script type="text/javascript">
    $(document).ready(function() {
        $("#quickSearch").click(function(){       
            var countries = [];
            $.each($("#select-choice-1 option:selected"), function(){ 
                countries.push($(this).val());
            });

    if (countries == "") {
            document.getElementById("txtHint").innerHTML = "";
            return;
        } else {    
            if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            } else {
                // code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    //myFunction(xmlhttp.responseText);


                    myFunction(xmlhttp.responseText);
                }
            }
        document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            xmlhttp.open("GET","webservices/getCountryDetails.php?q="+countries,true);
            xmlhttp.send();
        } 
        });
    });
    function myFunction(response) {
        var arr = JSON.parse(response);
        var i;
        var out = "<table>";

        for(i = 0; i < arr.length; i++) {
            out += "<tr><td>" +
            arr[i].Name +
            "</td><td>" +
            arr[i].City +
            "</td><td>" +
            arr[i].Country +
            "</td></tr>";
        }
        out += "</table>"
        document.getElementById("id01").innerHTML = out;
}
</script>

Firstly, countries will never be an empty string, you've defined it as an array

var countries = [];

...

if (countries == "") { // always fail

secondly, you can't concantenate an array into a string, and XMLHttpRequest doesn't accept arrays

xmlhttp.open("GET","webservices/getCountryDetails.php?q=" + countries, true);

Thirdly, you seem to be using jQuery, so why not use it as it does accept an array

$.ajax({
    url  : 'webservices/getCountryDetails.php',
    data : countries
}).done(myFunction);