If I run the simple code pasted below (with my app ID for
openweathermap obscured here) on Safari on my MacBook it works.
However if I deploy to volt and do the
same on Safari for iOS (10.2.1) it doesn’t. I have spent quite a bit of
time looking at jQuery / ajax conversations on your web board as well as
your documents, but it’s not clear why this wouldn’t work yet.
Thank you in advance for your ideas.
Steve
Function Button1_onclick()
Dim city, url
city = ""
url = "http://api.openweathermap.org/data/2.5/weather?
id=5037649&units=imperial&appid=XXXXXXc6cf60b36959641bb23fXXXXXX"
GetJSON(url, city, weatherData)
End Function
Sub weatherData(data)
MsgBox "Temperature is " & (data.main.temp )
End Sub
It doesn’t look like the GetJSON string query is passing the city. It’s been left empty. The format may require it. See Current weather data - OpenWeatherMap
The message means openweathermap is refusing to do what you’re asking. You’ll need to figure out what the site is looking for. You might check with them for help.
So, I used the same app, essentially, except I set up a simple JSON server on my network; which assumably would NOT have access control issues.
I can get the JSON string when running on a web page from “play” within Appstudio, but after deploying to volt and then running on my computer which is on the same network, it still get access control issues as shown above.
OK. Thank you for your help. I am wondering, then, that a project like LabWeatherSolution.nsx then would not be able to run from Volt because of CORS issues, correct?
I can disable or enable Cross-Origin Resource Sharing on the simple JSON server I’m running on my network. Using the nsbasic option “Start in Desktop Browser” I can see the error with CORS enabled and see the application work (shown above) with CORS disabled. Basically, I can turn the error on and off.
However by simply deploying to VOLT it doesn’t work in either case, instead showing the access control error:
Yes. That is correct. I am simply pinging that server on the address you mentioned, on an internal network, with a GetJSON request. If I type that address into any web browser it returns the JSON (on the internal network).
However using a GetJSON request in NSB (because it is based on XMLHttpRequest) is blocked because of the browser’s same origin policy.
I’m not sure how to get around it. I’d rather not write server side PHP - I have a pretty robust server that I can access written in node.js. But I’m stuck on how to make that work within Appstudio/NSB.
I think, If I understand your question, the answer is no. You’d have to be on my internal network to access that. And I don’t open up that internal port or forward it.
My use case is to have an iOS device pinging that server that is also sitting on the internal network however, so maybe I don’t understand Volt well enough yet to get my system architecture nailed down.