我现在只知道向后台发送数据,但是不知道该如何存储到指定A或者指定B,根据用户登陆的账户存储到该表信息
$('btn').onclick = function() {
var dat = ({ //json对象
'company': $('#company').value,
'Pnumber': $('#Pnumber').value,
'name': $('#name').value,
'fix_phone': $('#fix_phone').value,
'email': $('#email').value,
'qq': $('#qq').value,
'fax': $('#fax').value,
'ID': $('#ID').value,
'region': $('#region').value,
})
var str = JSON.stringify(dat);
var xhr = new XMLHttpRequest() || new ActiveXObject(Microsoft.XMLHttp);
xhr.open('post', 'zhuceye.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('data=' + str); //把json数据发送到php文件
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
var res = xhr.responseText;
//var aa=JSON.parse(res);
console.log(res);
if(res == 1) {
alert('修改成功');
}
}
}
开心每一天1111
ibeautiful