I have this code in PHP. I want to convert the syntax to JavaScript. Could you help me?
$id = "";
$auth_token = "";
if (preg_match("/&id\=([^&]+)/", $profile_url, $matches)):
$id = $matches[1];
preg_match("/&authToken\=([^&]+)/", $profile_url, $matches);
$auth_token = $matches[1];
endif;
I've tried this code:
var name, publicUrl, location, industry, company, position, inviteUrl, idToken, authToken;
$('input:checked').each(function () {
name = $(this).closest('tr').find('td.publicUrl a').text();
location = $(this).closest('tr').find('td.location').text();
industry = $(this).closest('tr').find('td.industry').text();
company = $(this).closest('tr').find('td.company').text();
position = $(this).closest('tr').find('td.position').text();
publicUrl = $(this).closest('tr').find(' td.publicUrl a').prop('href');
inviteUrl = $(this).closest('tr').find('td.inviteLink a').prop('href');
inviteUrl = text.match(/&id\=([^&]+)/);
idToken = match[1];
});
alert(idToken);
It doesnt alert anything at all.
This is the error. I can't understand the error because I already declared it and it has value: