arrays - Why does my code return the error "missing : after property id" in JavaScript? - Stack Overflow

How is this supposed to be written so that it would actually work?saveBuyerInfo( { 'save_'+$(

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
Add a ment  | 

1 Answer 1

Reset to default 8

You 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信