$.get(), $.post(), $.ajax()小练习
$.get(
'inc/detail.php',
{key: $(event.target).val()},
function (data,status){
console.log(status);
if (status === 'success') {
$('#detail').html(data);
$('[value=""]').remove();
} else {
$('#detail').html('<span style="color:red">请求错误</span>');
}
},
'html'
); $.post(
'inc/check.php',
{
email: email.val(),
password: password.val()
},
function(data) {
if (data.status === 1) {
$('button')
.after('<span style="color: green"></span>')
.next()
.html(data.message)
.fadeOut(2000);
} else {
$('button')
.after('<span style="color: red"></span>')
.next()
.html(data.message)
.fadeOut(2000);
}
},
'json'
);
$.ajax({
type: 'POST',
url: 'inc/check.php',
data: {
email: email.val(),
password: password.val()
},
success: function(data) {
if (data.status === 1) {
$('button')
.after('<span style="color: green"></span>')
.next()
.html(data.message)
.fadeOut(2000);
} else {
$('button')
.after('<span style="color: red"></span>')
.next()
.html(data.message)
.fadeOut(2000);
}
},
dataType: 'json'
})
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号