web前端|js教程
ajax,post,使用
web前端-js教程
列表带搜索源码,ubuntu路由怎么设置,爬虫人统治地球,php盗版,唐县网站seolzw
login.onclick = function(){var xhr = new XMLHttpRequest();xhr.open("get","http://localhost/ajax2/test2.php?username="+username.value+"&pwd="+pwd2.value,true);xhr.send();xhr.onreadystatechange = function(){if (xhr.readyState == 4) {if (xhr.status>=200 && xhr.status<300) {alert(xhr.responseText);};};}}
ajax方法
视频诱惑视频代源码,vscode开发串口助手,ubuntu 声卡 查询,yum安装tomcat位置,数据库数据导入sqlite,百度爬虫抓取次数不稳定,mac升级php版本,巴中seo优化怎么收费,门户网站模版,网站 古风模板lzw
btn.onclick = function(){ajax( "GET", "http://localhost/ajax2/my02.php", {xingming:xingming.value,pwd:pwd.value}, function(data){console.log(data);},function(errCode){console.log(errCode);})
post方法传参
java源码大全,乐鑫ubuntu镜像,爬虫的小应用,php centos,seo 网站 制作lzw
它与个get方法的区别:
01 安全型。post更安全。
02 速度. get的速度快
03 数量级。 post的数量级更大一些.
具体实现:
var xhr = new XMLHttpRequest();xhr.open("post","http://localhost/ajax2/login2.php",true);var data = {username:username1.value,pwd:pwd1.value}// 设置请求头 告诉服务器发给他的数据是json格式xhr.setRequestHeader("content-type","application/json");xhr.send( JSON.stringify(data) );xhr.onreadystatechange = function(){if (xhr.readyState == 4) {if ( xhr.status >= 200 && xhr.status < 300 ) {alert(xhr.responseText);};};}
原生jsonp 方法
var sc = document.createElement("script");sc.type = "text/javascript";document.body.appendChild(sc);sc.src = "http://localhost/ajax2/jsonp.php?cb=myCallBack";function myCallBack(data){console.log(data);}