I'd like to add a parameter after an URL in a Javascript function. The full URL I'd like to have is: https://my-url.com/section1/section2/here_a_random_number .json?lang=en This is the ".json?lang=en" that I'd like to add at the end of the URL.
Here my function (in a Google script, linked to a sheet):
function myfunction(randomnumber) {
var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber);
var jsonData = UrlFetchApp.fetch(myUrl);
var jsonString = jsonData.getContentText();
var jsonObject = JSON.parse(jsonString).result;
var name = (jsonObject.name);
Utilities.sleep(2000);
return name;
}
Where could I put/add my language parameter ?
只需将其添加到URL的末尾即可:
var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber) + ".json?lang=en";
try to replace
var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber);
by var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber)+".json?lang=en";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.