'json with variable url doesn't work on mobile
i'm struggling against json on mobile with a variable url. mobile browser can read correctly the data from some input fields with jquery, then I have to combine the values from the inputs to build up the correct json url.
this is my code, it works fine on desktop browsers but when I run the same from my mobile phone the script stops after the first console output.. getJSON never starts...
const account = "myaccountID";
$('#button').click(function(){
var Name = $('#name').val();
var Surname = $('#surname').val();
console.log(Name, Surname); // this output works on mobile but then stops
$.getJSON("https://mylink/api/"+account+"/item/"+Name+Surname, (data) => {
console.log(data); // this does not work on mobile
});
});
furthermore if I convert the url into an explicit url with no variable it works fine
$('#button').click(function(){
$.getJSON("https://mylink/api/myAccountID/item/NameSurname", (data) => {
console.log(data); // this is working fine
});
});
can someone give me some help! thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
