php jquery ajax提交

functionsearch_buyer(email){

varcontent='email='+$(email).val();

varurl='/index.php?r=admin/ajaxBuyer';

$.ajax(

{type:"post",

url:url,

data:content,

dataType:'json',

success:function(msg){

$('#ip').val(msg['info']['ip']);

$('#log')[0].innerHTML=msg['sendlog']['list'];

}

}

)

}

publicfunctionactionAjaxBuyer(){

$result=array();

try{

if(isset($_POST['email'])&&empty($_POST['email'])){

thrownewException('Email不能为空!');

}

$email=trim($_POST['email']);

if(!preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/",$email)){

thrownewException('Email格式有误!');

}

$result['data']=$model->getLastBuyerInfo($email);

}catch(Exception$e){

$result['errmsg']=$e->getMessage();

}

echojson_encode($result);

}

相关推荐