function saveProduct(id){
var jsonValue = '';
var iid = document.getElementById(id).parentNode.id;
var currentNode = document.getElementById(iid).childNodes;
for(var i = 0; i < currentNode.length; i++){
if(currentNode[i].nodeName == 'INPUT'){
var key = currentNode[i].id;
key = key.substr(0,key.length-1)
var value = currentNode[i].value;
jsonValue += key+':\"'+encodeURI(value,"UTF-8")+'\", ';
//alert((currentNode[i].id).substr(0,(currentNode[i].id).length-1) + ':' +currentNode[i].value);
}
}
// alert(jsonValue);
//jsonValue = jsonValue.substr(0,jsonValue.length-1)
jsonValue = "{" + jsonValue+"companyId:\""+$('#companyId').val()+"\"}";
$.post('<%=basePath%>share/savesp', jsonValue,
function(data){
alert(data.result); // John
}, 'json');
}
转载于:https://www.cnblogs.com/ganymede/p/3803786.html