您的位置:首页 > 编程语言 > PHP开发

php ajax学习

2014-02-21 22:09 232 查看
var table = document.getElementById("tableadd");//table的用法
for(var i = 1;i <= table.rows.length;i++)
var tr = table.rows[i];
function trimStr(str){return str.replace(/(^\s*)|(\s*$)/g,"");}
explode(",",$_POST['name']);分割字符串第一参数为分割标志
file_get_contents("php://input");  可以获取post方法传送的原始文本传递长文本就不用担心了
//post方法上传信息
//获取http对象
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		//Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		 }
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 }
	}
	return xmlHttp;
}
	//查看http请求是否成功
function checkhttp(){
	var http=GetXmlHttpObject()
	if (http==null){
		error();
		return null;
	}
	return http;
}
function getcontent(){
	gethttp = checkhttp();
	if(gethttp == null) return 0;
	var url;
	gethttp.onreadystatechange=getover;
	gethttp.open("POST",url,true);
	gethttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	gethttp.send(null);
	}
function getover(){
	if (gethttp.readyState==4 || gethttp.readyState=="complete") { 
		document.getElementById("Introduce").innerHTML = gethttp.responseText;
 	 } 
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: