Hi.
I'm working on a mobile app.
So I'm trying to get some images from external URLs. The URL is being generated depending on the country selected, and 90% of them are working. But in some cases, that URL doesn't exist, and when that happens, the mini image view is displayed, as showed below. So, what I want to do, is to alter this nonexistent image with some text, p.e "Country Image not found!". I tried to put the image in an if, controlled by a variable, whose state is changed by JS code when a country is selected. But that JS, below too, always returns false, even in the cases where the URL is valid. Another obs: Even if inside the JS it's only a "$parameters.IsSuccess = true", nothing else, the output return is always false.
I will appreciate any help.
Hi Joao,
Based on the shared JS code snippet, I have observed that the ImageExists function defintion is available/defined but invoking/calling of the function is missing i.e. ImageExists();
I have tried to implement the mentioned use-case by using the same JS code but it's not woking (throwing cross-domain console error).
The solution which I found working is https://stackoverflow.com/a/18837818
See this sample app ExternalImageUrlDemo
More info about - $resolve();
Refer to the attached .oml file
Hope this helps you!
Kind regards,
Benjith Sam
Hi. Thank you for your response. It worked on perfection. I thought that I didn't need to invoke the function since it was alone there. It's working now.
You're welcome, Joao.
Glad to help you :)
Why don't you check with another HTTP status, like 404?
Hi. 404 was my first attempt, but it didn't work. And as I said, the JS output, is always returning false, even if the function is so simple as:
function imageExists(){
return $parameters.IsSuccess = true;
}
Hi,
Perhaps you could use the action HTTPHead of ardoHTTP. With this action, you can check the http status code.
Kind regards, David.
Hi. Unfortunately, it didn't work. I found out that the image status is always 200, finding the image or not. When the link doesn't have the image, it automatically gets a redirect to the main page screen, and I assume that as the reason for the status 200 (which I found weird since redirect has a different HTTP status.).