应该如何编写才能使其真正起作用?
saveBuyerInfo(
{ 'save_'+$("#textAreaXMLPostRequest").attr('name') :
$("#textAreaXMLPostRequest").val() } );
最佳答案
您不能将表达式作为对象字面量中的键。相反,首先创建您的对象:
var save = {};
save['save_' + $("#textAreaXMLPostRequest").attr('name')] = $("#textAreaXMLPostRequest").val();
saveBuyerInfo(save);
关于javascript - 为什么我的代码在 JavaScript 中返回错误 "missing : after property id"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/664166/