Post:
$(function(){ var responseMsg = $('#responseMsg'); responseMsg.html(''); $('#loginBt').click(function(){ var username = $('#username').val(); var password = $('#password').val(); var url = "login.do"; $.post(url, {account:username,password:password}, function(data, status){ console.log('data: ' + data) if(data.description == 'Success'){ var strFullPath=window.document.location.href; var strPath=window.document.location.pathname; var pos=strFullPath.indexOf(strPath); var prePath=strFullPath.substring(0,pos); var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1); window.location.href=prePath + postPath + '/page/home.html'; } else { responseMsg.html('Invalid username or password'); } }) }) });
Get:
var url = "login.do?username="+username+"&password="+password; $.get(url, function(data, status){ if(data.description == 'Success'){ var strFullPath=window.document.location.href; var strPath=window.document.location.pathname; var pos=strFullPath.indexOf(strPath); var prePath=strFullPath.substring(0,pos); var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1); window.location.href=prePath + postPath + '/page/home.html'; } else { responseMsg.html('Invalid username or password'); } })
ajax post:
$.ajax({ url : url, beforeSend : function(){ ajaxLoading(); }, type : 'POST', data : { submit_time_from : submitTimeFrom, submit_time_to : submitTimeTo, corp_id : corpId, }, success : function(data, status){ ajaxLoadEnd(); if(data == 'Please login first'){ responseMsg.html(data); return; } var statusCode = data.code; if (statusCode == '0') { responseMsg.html(data.description); } else { responseMsg.html(data.description); } } });
function ajaxLoading(){ $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body"); $("<div class=\"datagrid-mask-msg\"></div>").html("Being handling, please wait...").appendTo("body").css({display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2}); } function ajaxLoadEnd(){ $(".datagrid-mask").remove(); $(".datagrid-mask-msg").remove(); }
相关推荐
本项目使用了jQuery的get/post两种方法提交Json格式的数据到后台,后台再把Json格式的数据传到前台。实现了JSON字符串和JSON对象之间的转换。
jquery异步调用post get方式
jquery-get-post-load 方法
jQuery ajax、post、get、json格式传递数据例子 jQuery ajax、post、get、json格式传递数据例子
NULL 博文链接:https://xiongjiajia.iteye.com/blog/1563477
PHP+Jquery+AJAX POST,GET提交表单并接收返回
$.get()和$.post()方法 、 $.getScript()和$.getJson() 、 $.ajax()方法 、 序列化元素 、 jQuery中的Ajax全局事件 这些都有详尽的例子,一看代码,你就能明白jquery里实现ajax是怎么回事了,简单明了。
jquery由GET转成POST方法工具类,传入一个URL链接地址,直接把链接地址转换并POST提交。
主要介绍了Jquery AJAX POST与GET之间的区别详细介绍的相关资料,需要的朋友可以参考下
其次详细讲解了jQuery的各种选择器、jQuery操作DOM的方法、jQuery中的事件与应用、jQuery中的动画和特效、Ajax在jQuery中的应用,以及各种常用的jQuery插件的使用方法和技巧,所有这些知识点都配有完整的示例(包括...
详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON()
JSON数据前后传输例子,post,get请求例子,jquery
在JQuery中可以使用get,post和ajax方法给服务器端传递数据 get方法的使用(customForGet.js文件): function verify(){//1.获取文本框的数据 //通过DOM的方式获取//document.getElementByIdx(“userName”);//通过...
详细介绍了jquery 的ajax 的基本应用,如post和get和ajax三种方式。简单易懂
asp+ajax(jQuery)实例($.ajax()、$.post()、$.get()、$.getJSON()四种模式可选 Ajax是目前比较流行的网站建设技术,尤其作为网站建设者来说,掌握它十分有必要,如果用原生Javascript开发则比较困难,还好有强大的...
JQuery中ajax,get方法在ashx,aspx,asmx中的使用,分别是在aspx页面,ashx页面,webService页面三种列举了案例,分别使用了GET和POST两种方式的请求,请求类型类型包含有text,json,xml.本案例全面,内容基础易懂,特别适合...
在jquery中ajax提交表单有post与get方式,在使用get方式时我们可以直接使用ajax 序列化表单$( 表单ID) serialize();就行了,下面我来介绍两个提交表单数据的方法。$get方式提交表单get() 方法通过远程HTTP ,下面我...
jquery是js的类库,js本身不能操作header,因为js是在浏览器加载页面过程中才开始执行的header需要服务器端执行操作 如果是ajax,是可以设置header $.ajax({ url: "", data: {}, type: "GET", beforeSend: ...
jqueryajax的$post和$get方法共3页.pdf.zip
在项目中,如果需要传递一些参数给服务器中的页面,那么可以使用$.get()或者$.post()方法(或者是$.ajax()方法) $.get()方法使用GET方式来进行异步请求。结构为:$.get(url [, data] [, callback] [, type]) $.get()...