ajax请求数据格式
type是请求的类型包含了get和post
url:请求的地址
data:传递的参数
dataType :数据格式,可以是html,json
返回成功之后进入到success 函数
返回失败之后进入到error函数
<script type="text/javascript">
function doLogin(type) { $.ajax({ type : "GET", url : "login.do", data : { username : $("#username").val(), password : $("#password").val(), type : type }, dataType : "json", //预期服务器返回的数据 success : function(data) { if (data.errCode < 0) { alert("登录失败!") $("#errMsg").show().html(data.errMsg).stop(true, true) .fadeOut(3000); } else { //登录成功,做其他处理 alert("恭喜你,登录成功!"); } } }); } </script>转载博客:https://www.cnblogs.com/1906859953Lucas/p/10828801.html
本文来自博客园,作者:.net&new,转载请注明原文链接:https://www.cnblogs.com/wugh8726254/p/12644202.html
浙公网安备 33010602011771号