ajax代码:
==========================================================================================================
ajax.js
var xmlHttp;
function creatXMLHttpRequest() {
if(window.ActiveXObject) {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
} else if(window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(id,url) {
creatXMLHttpRequest();
xmlHttp.onreadystatechange = function(){handleStateChange(id);}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function handleStateChange(id) {
if(xmlHttp.readyState == 1) {
document.getElementById(id).innerHTML = "<div class='cs'>正在加载请稍等...</div>";
}
if(xmlHttp.readyState == 4 ){
if(xmlHttp.status == 200) {
var allcon = xmlHttp.responseText;
document.getElementById(id).innerHTML = allcon;
//alert(allcon);
}
}
}php代码:
==========================================================================================================
<?php
require_once('include/conn.php');
header('Content-Type:text/html;charset=GBK');
if($_GET['name']!=''){
$uname=$_GET['name'];
sleep(1);
$strsql="SELECT * FROM tb_user WHERE userMobile='$uname'";
$result=mssql_query($strsql);
$rows=@mssql_num_rows($result);
if($rows>0){
echo "<font color=red>"."已被注册!"."</font>";
}else{
echo "<font color=red>"."此用户名未被注册!"."</font>";
}
}else{
echo "<font color=red>"."用户不能为空且为手机号"."</font>";
}
?>html页面代码:
==========================================================================================================
<input name="userMobile" type="text" id="userMobile" maxlength="11" onblur="startRequest('ajaxcls','eee.php?name='+this.value);"/></td>
==========================================================================================================
ajax.js
var xmlHttp;
function creatXMLHttpRequest() {
if(window.ActiveXObject) {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
} else if(window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(id,url) {
creatXMLHttpRequest();
xmlHttp.onreadystatechange = function(){handleStateChange(id);}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function handleStateChange(id) {
if(xmlHttp.readyState == 1) {
document.getElementById(id).innerHTML = "<div class='cs'>正在加载请稍等...</div>";
}
if(xmlHttp.readyState == 4 ){
if(xmlHttp.status == 200) {
var allcon = xmlHttp.responseText;
document.getElementById(id).innerHTML = allcon;
//alert(allcon);
}
}
}php代码:
==========================================================================================================
<?php
require_once('include/conn.php');
header('Content-Type:text/html;charset=GBK');
if($_GET['name']!=''){
$uname=$_GET['name'];
sleep(1);
$strsql="SELECT * FROM tb_user WHERE userMobile='$uname'";
$result=mssql_query($strsql);
$rows=@mssql_num_rows($result);
if($rows>0){
echo "<font color=red>"."已被注册!"."</font>";
}else{
echo "<font color=red>"."此用户名未被注册!"."</font>";
}
}else{
echo "<font color=red>"."用户不能为空且为手机号"."</font>";
}
?>html页面代码:
==========================================================================================================
<input name="userMobile" type="text" id="userMobile" maxlength="11" onblur="startRequest('ajaxcls','eee.php?name='+this.value);"/></td>
解决方案 »
- 关于codeigniter中整合ck的一些问题 求指点
- PHP不能使用domxml_open_mem() 方法,在哪下载php_iconv.dll,php_domxml.dll文件
- 求路过的高手,帮小弟解决一个php取用API的问题呀!
- 学php该从何学起?
- Apache2.2.8+PHP5.2.6 启动时提示Unable to load dynamic library
- 求解,正则表达式高手~
- 原来用IIS配置的PHP下PHP页面显示正常,不过如今换成Apache2之后居然全是乱码?怎么回事?
- 上传图片到mysql数据库中怎么老有问题?
- windows server 2008 php IIS 使用 uploadify上传大文件 无法上传
- PHP框架无法读取配置文件
- 求解网页排版!~~~在线等!
- MySQL 5.1分区技术初探(一)
php 程序里有
header('Content-Type:text/html;charset=GBK');
可知你的页面也是 gbk 的,这样在处理中文时要出问题的