function postdata(){
var params = "";
params += "&terminal=" + document.getElementById('terminal').value;
$.ajax({
type: 'POST',
url: 'bing.php',
data: params,
success: function(data){
var re[code="java"]
sult;
eval("result=" + data + ";");
alert(result.message);
}
});
}
<?php
define('IN_ECS', true);
define('INIT_NO_USERS', true);
define('INIT_NO_SMARTY', true);
require(dirname(__FILE__) . '/includes/init.php');
require(ROOT_PATH . 'includes/cls_json.php');
$username ='123';
$terminal =$_REQUEST['terminal'];
if ((DEBUG_MODE & 2) != 2)
{
$smarty->caching = true;
}
$countsql = "select * from ecs_users where terminal_id='$terminal'";
$res = $GLOBALS['db']->getAll($countsql);
$arr['message']='';
if(count($res)==0)
{
$sql="update ecs_users set terminal_id='$terminal' where user_name='$username'";
$GLOBALS['db']->query($sql);
$arr['message']='绑定成功!';
}else
{
$arr['message']='阅读器已经绑定!';
}
$json = new JSON;
echo $json->encode($arr);
?>[/code]