jsp页面中的ajax:
$(document).ready(function (){
$.ajax({
url:'AjaxServlet',
url:'http:192.168.10.2/jspTophp.php';
type:"POST",
dataType:'json',
data:"act=testid",
success:function(data){
$(data).each(function(){
var eid=$(this).attr("eid");
$("#testid").append("<option value="+eid+">"+eid+"</option>");
})
}
}),
error:function(){
alert("error!");
};
php页面:
<?php
#
NCR project
Copyright (c) 2009-2012 BJHIT.com.
All rights reserved.
#
require("defs.php3");
$result = DBQueryFatal("select eid,start_time,end_time from testbed_history");
$jsonarr=array();
$i=0;
while ($row = mysql_fetch_array($result))
{
$eid = $row["eid"];
$start_time=$row["start_time"];
$end_time=$row["end_time"];
$jsonarr[$i]=array('eid'=> $eid,'start_time'=> $start_time,'end_time'=> $end_time);
$i++;
}
$json_str=json_encode($jsonarr);
echo $json_str;
?>
jsp页面上的ajax执行了error:function