Good afternoon! I'm not very good at js, I ran into dynamic VK authorization. I can not correctly set the path after receiving the data. Checked on sites, wrote the wrong syntax. Help me please.

 VK.Widgets.Auth ("vk_auth", {width: "200px", onAuth: function (data) {location = 'http: //ctfdev.ru? Id_vk =' + data ['uid'] + '& name =' + data ['first_name'] + '& last_name =' + data ['last_name'] + '& photo_big =' + data ['photo'] + '& photo_mini =' + data ['uid'] + '& hash =' + data ['hash'] ';}}); 
  • In order to "connect variables with text" in es6 there is a template string ( es6-features.org/#StringInterpolation ), and in es5, yes, a purely plus sign. - Duck Learns to Take Cover
  • when the wrong syntax - the browser console, at least, shows what exactly this error is - Alexey Shimansky

1 answer 1

You have an extra mark at the end

+ data ['hash'] '

In general, variables are connected to the text with the “+” sign, as you did

<script type="text/javascript"> VK.Widgets.Auth("vk_auth", {width: "200px", onAuth: function(data) { location='http://ctfdev.ru?id_vk='+data['uid']+'&name='+data['first_name']+'&last_name='+data['last_name']+'&photo_big='+data['photo']+'&photo_mini='+data['uid']+'&hash='+data['hash']; } }); </script> 
  • Thank you, did not notice - Fair Man