How is this supposed to be written so that it would actually work?
saveBuyerInfo(
{ 'save_'+$("#textAreaXMLPostRequest").attr('name') :
$("#textAreaXMLPostRequest").val() } );
How is this supposed to be written so that it would actually work?
saveBuyerInfo(
{ 'save_'+$("#textAreaXMLPostRequest").attr('name') :
$("#textAreaXMLPostRequest").val() } );
Share
edited Mar 19, 2009 at 22:53
GEOCHET
21.3k15 gold badges77 silver badges99 bronze badges
asked Mar 19, 2009 at 21:32
thirsty93thirsty93
2,6526 gold badges26 silver badges26 bronze badges
2
- What's the problem with that? – Seb Commented Mar 19, 2009 at 21:38
- @Seb — He's trying to use an expression on the left-hand side. – Ben Blank Commented Mar 19, 2009 at 21:39
1 Answer
Reset to default 8You can't have an expression as the key in an object literal. Instead, create your object first:
var save = {};
save['save_' + $("#textAreaXMLPostRequest").attr('name')] = $("#textAreaXMLPostRequest").val();
saveBuyerInfo(save);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745060955a4608963.html
评论列表(0条)