php ajax学习

来源:互联网 发布:java读取图片返回前台 编辑:程序博客网 时间:2024/06/11 05:35

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+, SafarixmlHttp=new XMLHttpRequest();}catch (e){//Internet Explorertry{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;  } }


0 0