新手请问.get方法怎么使用

WBOY
Release: 2016-06-13 11:38:11
Original
1082 people have browsed it

新手请教.get方法如何使用
刚学jquery,试了一个例子,有两个页面index.html,data.php,但每次执行都显示的都是乱码,请问该怎么办?

index.html

nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

 


   New Document 
  
  
  
  
  
 

 
  


Show list of:



  

  <script></script>
  <script><br /> $(document).ready(function(){<br /> $('#choice').change(function(){<br /> if($(this).val()!='')<br /> { <br /> $.get(<br /> 'data.php',<br /> {what:$(this).val()},<br /> function(data){<br /> $('#result').html(data);<br /> });<br /> }<br /> });<br /> });<br /> </script>
 




data.php



if($_GET['what']=='good')
{

$names=array('Sherlock Helmes','John Watson','Hercule Poirot','Jane Marple');

echo getHTML($names);
}
else if($_GET['what']=='bad')
{

$names=array('Professor Moriarty','Sebastian Moran','Charles Milverton','Von Bork','Count Sylvius');

echo getHTML($names);
}

function getHTML($names)
{
$strResult='
    ';
    for($i=0;$i {
    $strResult.='
  • '.$names[$i].'
  • ';
    }
    $strResult.='
';
return $strResult;
}

?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template