[英]Can anyone tell me why I am getting Uncaught SyntaxError: Unexpected string?
This is my code below. 这是我的下面的代码。
The error I get above will not move, I am trying lots of different variants. 我上面得到的错误不会移动,我正在尝试许多不同的变体。
var $token = $(this).attr('id');
var $itemId = $(this).find('input.id').val();
var $instaUrl = 'https://api.instagram.com/v1/media/"'.$itemId.'"/likes?access_token="'.$token.'"';
console.log($instaUrl);
Thanks 谢谢
JavaScript uses +
for string concatenation: JavaScript使用
+
进行字符串连接:
var $token = $(this).attr('id');
var $itemId = $(this).find('input.id').val();
var $instaUrl = 'https://api.instagram.com/v1/media/"'+$itemId+'"/likes?access_token="'+$token+'"';
console.log($instaUrl);
You used the dot ( .
) from PHP. 您使用了PHP中的点(
.
)。
By the way, you do not need to use a dollar sign for variables in JavaScript! 顺便说一句,您不需要为JavaScript中的变量使用美元符号!
Use +
for concatenation in javascript.It can also be done using the following methods: 在JavaScript中使用
+
进行串联。也可以使用以下方法完成:
a. 一种。 The addition operator (
+
) 加法运算符(
+
)
b. b。 The assignment operator (
+=
) 赋值运算符(
+=
)
c. C。 The built-in
concat
method 内置的
concat
方法
ar $token = $(this).attr('id');
var $itemId = $(this).find('input.id').val();
var $instaUrl = 'https://api.instagram.com/v1/media/"'+$itemId+'"/likes?access_token="'+$token+'"';
console.log($instaUrl);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.