$(ajax) jquery+ajax 交互

$(":radio[name='time']").click(function(){
    $("#show_teacher_freetime").html("");
    var flag = $(this).attr("value");
    var courseid = $("#courseid").attr("value");
    $.ajax({
	url:"record_students_month.php?act=getteacher",
	type:"POST",
	dataType:"json",
	data:{"flag":flag,"courseid":courseid},
	error:function(data1,data2){alert('error');},
	beforeSend:function(){},
	success:function(data){
	    for(var i=0;i<data.length;i++){
		var _html = "<tr><td></td>";
		_html+= "<td>"+data[i].userid+"<br/>";
		_html+= "<a href='/member.php?mid="+data[i].mid+"' target='_blank'>了解老师</a></td>";
		$("#show_teacher_freetime").append(_html);
	    }
	}
    });
});

后台代码

case 'getteacher':

	$day=$_POST["flag"];
	$courseid=$_POST['courseid'];
	$tomorrow=date('Ymd',strtotime(date('Ymd'))+86400);
	$starttime = strtotime(date("Ymd"))+86400+$day*60*60;
	
	$sql="SELECT * from `dede_member_calendar` where ymddate=$tomorrow ";	 //$tomorrow
	$row=$db->Execute('Knight',$sql);
	$edgarDatas = array();
	$tearry = array();
        while(($data = $dsql->GetArray("Knight")) != false) {
            $edgarDatas[] = $data;
        }
        foreach($edgarDatas as $v){
            $status = is_teacher_yuyue($starttime,$mid,$courseid);
                if(!$status){
                    ShowMsg1('您申请的上课时间已有其它学员预约,请重新提交',$referurl,'jg.png');
                    exit();
                }
        }
	exit(json_encode($tearry));
	break;
提交验证表单

function checkSubmit(){
	if(!$(":radio[name='time']").is(":checked") || !$(":radio[name='tmid']").is(":checked"){
		alert('请填写正确预约信息后再提交!');
		return false;
	}
	return true;
}

你可能感兴趣的:(jquery,Ajax)