php ajax学习

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;
 	 } 
}


你可能感兴趣的:(php ajax学习)