views:

1350

answers:

1

How is this supposed to be written so that it would actually work?

saveBuyerInfo( 
    { 'save_'+$("#textAreaXMLPostRequest").attr('name') :
    $("#textAreaXMLPostRequest").val() } );
+6  A: 

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);
Ben Blank
It's a shame, really. I was just looking for an unanswered question to test a Greasemonkey script on, without answering. Just my luck that it turned out to be something I knew! ;-)
Ben Blank