Jquery Ajax用于从php mysql获取数据而不刷新页面 - 语法错误[关闭]

I need to get data from mysql database without refreshing the page using jquery ajax. I have a php script which is working fine. However, my JS seems to be having some problem. Here is the jquery script. Also, I am using multiple jquerys on same page like maximage and custom scrollbar.

var count = jQuery.noConflict();

count('#CountryName').on ('change',function(){ 
var Country = count('#CountryName').val();
count.ajax({ 
  type: 'GET' ,
  url: 'getcountry2.php', 
  data: 'q=', 
}).done(function( html ) { 
 count('#result').append(html); 
 or 

  count('#result').html(html); 
});
});

Here is my php

<link href="main2.css" rel="stylesheet" type="text/css" />
<link href="country.css" rel="stylesheet" type="text/css" />
<?php
$q=$_GET["q"];

$con = mysql_connect('localhost', 'root', 'password');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$user = mysql_real_escape_string($user);
$pwd = mysql_real_escape_string($pwd);

mysql_select_db("mahc", $con);

$sql="SELECT * FROM texttesti WHERE Country = '".$q."'";

$result = mysql_query($sql);

echo "<div>";

    while($row = mysql_fetch_array($result))
      {

    echo "<blockquote>". $row['Review'] ."</blockquote>";

    echo "<p>" . $row['Name'] . " " . $row['ReasonForPanchakarma']."</p>";
    }
echo "</div>";

mysql_close($con);
?>

Here is my HTML

<p>Select the Fields below to see the testimonials of your choice:</p>
   <p>  <form name="Country">
 <select id="CountryName" onChange="showCountry(this.value)">
<option value="">Select a Country:</option>
<option value="USA">USA</option>
<option value="India">India</option>
<option value="Germany">Germany</option>
<option value="Russia">Russia</option>
</select>
</form>
</p>
<div id="result_data">
<script type="text/javascript" src="country2.js"></script>
</div>
</div>

Use simple ajax as:

  $.ajax({
   url:'getcountry2.php',
   datatype:"application/json",
   type:'get',
   data: 'q='+Country, 
   success:function(data){
      count('#result').append(html); 
   },
   error:function(){
      // code for error
   }
 });

hopw it will help!

You didn't pass country value to PHP but you are getting the value in PHP. So it could be a problem. Try this,

count.ajax({ 
  type: 'GET' ,
  url: 'getcountry2.php', 
  data: 'q='+Country, 

Here you go..Country is missing

var count = jQuery.noConflict();

    count('#CountryName').on ('change',function(){ 
    var Country = count('#CountryName').val();
    count.ajax({ 
      type: 'GET' ,
      url: 'getcountry2.php', 
      data: 'q='+Country, 
    }).done(function( html ) { 
     count('#result').append(html); 
     or 

      count('#result').html(html); 
    });
    });