$.ajax({
method: "POST",
url: "api.php",
data: {
userid: '1',
},
dataType: 'json',
cache: false,
success: function(value) {
if (value.status == 'success') {
swal({
title: "success!",
text: value.msg,
type: "success"
});
} else if (value.status == 'error') {
swal({
title: "error!",
text: value.msg,
type: "error"
});
};
},
error: function() {
swal("ERROR");
}
});
动态增加一个内容到HTML:
$('#id').html('23');//#id or .classname

这些代码看不懂
ajax还有种简单的写法就是一个函数,$post $get ajax请求更简单,不过好久不写jQuery了,O(∩_∩)O哈哈~