为方便起见,我把上一个记事分成了两部分,上面对遇到的问题进行总结,这部分对问题和非自己写的代码进行整理。
<script>
$(function(){
if(<?php echo $status;?>)
$("input[value='1']").attr("checked",true);
else
$("input[value='0']").attr("checked",true);//attr() 方法设置或返回被选元素的属性值。这是对设置开关的状态的判断
$("#site_switchSubmit").click(function(){
$.ajax(
{
url:"/?a=center.account.webon",
type:"post",
data:
{
flag:$("input[name='radiobutton']:checked").val()
},
dataType:"json",
success:function(rs)
{
alert(rs.msg);
}
})
})
})
</script>
<?php
$tempPath=$_SITE_PATH_."web/enterpriseMod/$template/upgrade.html";
$tempContent=file_get_contents($tempPath);
echo($tempContent);
?>
<a href="/?a=e.index&sid=1674433" target="_blank">如果您有需要点此进入查看!</a>
$str = file_get_contents("domain/bz.sotxsports.com.txt");
$status=1;
if(strpos($str,"e.index")===false)
{
$status=0;
}
require_once CENTER_V. 'account/site_switch.php';
?>
$path = "domain/bz.sotxsports.com.txt";
$content = file_get_contents($path);
$arr = json_decode($content);
if($_POST['flag']) {
$arr->default_url=str_replace("upgrade","index",$arr->default_url);
}
else {
$arr->default_url=str_replace("index","upgrade",$arr->default_url);
}
$flag = file_put_contents($path,json_encode($arr));
$rs=new stdClass();
if($flag) {
$rs->type="success"; $rs->msg="操作成功";
} else {
$rs->type="success"; $rs->msg="操作失败";
}
echo json_encode($rs);
?>