var parme = {
username: username.value,
mobile: phone.value,
sex: sex,
city: '杭州'
}
// 源生
var xhr = new XMLHttpRequest();
xhr.open('POST', '/');
// xhr.setRequestHeader("token",token) //请求头携带参数(token)
// xhr.setRequestHeader("Accept",'application/json, text/javascript, */*') // 修改请求头Accept属性
xhr.send(JSON.stringify(parme));
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
console.log('success', xhr.responseText);
} else {
console.log('error', xhr.responseText);
}
}
//jq
$.ajax({
type: "POST",
url: "",
data: parme,
dataType: "json",
success: function(data){
$('#success').animate({
top: '0px'
}, 500)
setTimeout(function() {
$('#success').animate({
top: '-40px'
}, 500)
}, 3000)
}
});
网友评论