You're passing a JSON string to handle.exec, which is turned into a JS object in a different place to where your x variable is defined, and thus causing the error.
Instead, let x be resolved as part of the string and it should work:
handle.exec( ... , '{"plotindex": 0, "values": ['+x+']}');