Post function sendRequest(url) {
createRequest();
request.open("POST", "/json/login1", true);
request.onreadystatechange = updatePage;
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("uname="+uname+"&psw="+psw);
}
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var res = request.responseXML.getElementsByTagName("res")[0].firstChild.data;
window.alert(res);
} else {
alert("status is" + request.status);
}
}
}
function userCheck(){
uname = document.getElementById("uname").value;
psw = document.getElementById("psw").value;
if(uname=="") {
window.alert("用户名不能为空。");
document.getElementById("uname").focus();
return false;
}
else {
sendRequest();
}
}
Get
function sendRequest(url) {
createRequest();
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var res = request.responseText;
window.alert(res);
} else {
alert("status is" + request.status);
}
}
}
function userCheck(){
var uname = document.getElementById("uname").value;
var psw = document.getElementById("psw").value;
if(uname ==""){
window.alert("用户名不能为空!");
document.getElementById("uname").focus();
return false;
} else{
sendRequest('/json/login?uname='+uname+'&psw='+psw);
}
}
分享到:
相关推荐
AJAX POST与get提交数据的差别,喜欢了解详细内容的朋友可以下载学习!
Ajax中Get请求和Post请求的区别 简单例子 何时使用Get请求,何时使用Post请求
jQuery ajax、post、get、json格式传递数据例子 jQuery ajax、post、get、json格式传递数据例子
Ajax中POST和GET的区别
Java 模拟Ajax POST GET 提交代码,实测很好用。
PHP+Jquery+AJAX POST,GET提交表单并接收返回
$.get()和$.post()方法 、 $.getScript()和$.getJson() 、 $.ajax()方法 、 序列化元素 、 jQuery中的Ajax全局事件 这些都有详尽的例子,一看代码,你就能明白jquery里实现ajax是怎么回事了,简单明了。
php+Ajax解决了post与get中文乱码的问题 后台页面可以结合mysql使用,以达到相应目的
学习ajax技术的时候,很多同学对于ajax中get与post请求总是疑问不解
Ajax Get、Post请求 Ajax Get、Post请求 Ajax Get、Post请求
服务端模拟ajax,支持发起GET、POST、PUT、DELETE请求
封装jquery ajax方法,方便调用,避免在代码中频繁使用 $.ajax({ type: 'GET', url: url, ...... )}; 统一调用公共方法即可,区分同步异步,get post!希望对大家有帮助
用AJAX的Get和Post调用Servlet的简单示例
function Ajax(url,method,parameter,onSuccess,onError,onLoad){ this.xmlHttp=null; this.url=url; this.method=method; this.parameter=parameter; this.success=onSuccess?onSuccess:null; this.error=on...
ajax以GET和POST方式调用WCF,带参数和不带参数的方式都有
查了很多资料都说,get方法的参数是有限制的,post方法的参数的长度是无限制,这也是post相比get的优势一直。 在ajax中使用post方法,用常规的参数格式:param1=a1¶m2=a2 ,当参数长度过长时,依然提交不成功。...
ajax总结,load,get,post,ajax总结,还有formdata~~~
详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON()
本项目使用了jQuery的get/post两种方法提交Json格式的数据到后台,后台再把Json格式的数据传到前台。实现了JSON字符串和JSON对象之间的转换。
asp+ajax(jQuery)实例($.ajax()、$.post()、$.get()、$.getJSON()四种模式可选 Ajax是目前比较流行的网站建设技术,尤其作为网站建设者来说,掌握它十分有必要,如果用原生Javascript开发则比较困难,还好有强大的...