前端修改数据之后,需要把修改后的字段信息发送给后台的数据都是放在post请求的data中就可以了吗
window.onload= function(){
var xhr = new XMLHttpRequest();
var msg = {"name":"zqian","age":"17"};
xhr.open('post','http://rap2api.taobao.org/app/mock/12040/ptest',true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send(JSON.stringify(msg));
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status >=200 && xhr.status <300 ||xhr.status ==304){
console.log(xhr.response);
}
}
}
FanlyBaby
相关分类