python测试开发(06-前端[HTML,JS,CSS]+ajax请求)

1.HTML

2.JS

var i = 0;
while (i < 10) {
console.log(i);
i++;
}

for (var j = 0; j < 10; j++) {
console.log(j)
}

// for in:遍历循环
// 遍历数组
var aList=Array( 11,22,33,44,55);
for(i in aList){
console.log(i); //遍历数组的下标
console.log(aList[i]) //遍历数组的值
}

// 遍历对象:遍历出来的是属性
var obj={
name:'yuan',
age:18,
gender:'male'
}
for(i in obj){
console.log(i);
console.log(obj[i])

}

3.CSS

4.ajax两种请求方式:


$(function () {
// ajax请求
$('#dl').click(function () {
// 获取账号
var user=$('#username').val();

// 获取密码
var pwd=$('#password').val();

// 相关加密处理--->先不处理,后台要解密

// 发送ajax请求
// // 方式一:
// $.ajax({
// // ajax三种重要属性:url,type,success
// url: '/login/',
// data:{"user":user,"pwd":pwd},
// type:'POST',
// // 请求数据类型
// dataType:'json',
// // 请求成功会当作参数返回成功给data
// success:function (data) {
// // 判断数据有木有被返回
// if(data.code=='1'){
// alert(data.msg)
// }else{
// // 弹出提交失败的弹框
// // alert(data.msg)
// // ajax的请求方式
// $(this).text().append(data.msg);
// }
//
// }
})
// 方式二:done和fail现在用的比较多
$.ajax({
// ajax三种重要属性:url,type,success
url: '/login/',
data: {"user": user, "pwd": pwd},
type: 'POST',
// 请求数据类型
dataType: 'json',

}).done(function (data) {
if(data.code=='1'){
alert(data.msg)
}else {
// 弹出提交失败的弹框
// alert(data.msg)
// ajax的请求方式
$(this).text().append(data.msg);
}
}).fail(function (data) {
alert("请求失败!")
})

})

猜你喜欢

转载自www.cnblogs.com/vivian0119/p/12038315.html