function transport2()//删除文章
{
var b = '';
var a=document.getElementsByName('item1');
for(i=0;i
if(a[i].checked)
{
var c =a[i].value;
b=b+c+',';
}
}
alert(b);//b能正常输出,比如12,15,
var postStr="del_me="+b;
S_xmlHttpRequest();
xmlHttp.open("POST","delete.php",true);
xmlHttp.setRequestHeader("cache-control","no-cache");
xmlHttp.onreadystatechange=byphp2;
xmlHttp.send(postStr);
}
function byphp2()
{
if(xmlHttp.readyState == 4 {
if(xmlHttp.status == 200)
{
var sousoft=xmlHttp.responseText;
alert(sousoft);
}
}
}
delete.php
header('Content-Type:text/html;charset=GB2312');
echo $_POST[del_me];//这个值始终为空,我想应该为ajax.js中b的值吧
include_once('../Mysql.php');
$del_me=explode(",",$_POST[del_me]); //分割,存入数组
if(count($del_me)>0){
foreach($del_me as $value)
{
$mysql=new Mysql("localhost","root","....","sousoft");
$result1=$mysql->query("delete from book where serial='$value'");
//mysql_free_result($result1);
}
echo"删除成功";
}
$mysql->close_db();
?>
注释说明了