How set the output variable "{{msg.payload}}" in JS?!

The short answer is that you cannot access msg.payload directly from inside your browser's <script>...</script> elements -- please read through the answers given on this recent discussion thread.