Can I LoadString(txt file) from the internet/web?
Monkey Targets Forums/iOS/Can I LoadString(txt file) from the internet/web?| 
 | ||
| Hello, Subj. I go like: 
oldPriceFile = app.LoadString("http://white-zebra.com/oldprice.txt")
=> oldPriceFile is an empty string. | 
| 
 | ||
| Use brl.httprequest to load strings asynchronously. Example: http://source.mungo.io/docs/samples/blob/master/mak/httprequest/httprequest.monkey | 
| 
 | ||
| hello.  this don't work on html5 target | 
| 
 | ||
| programmer, Thank you! Works as a charm on iOS. DiabloV, Yes, doesn't work on html5. | 
| 
 | ||
| Are you trying to load text on the same domain or different domain? Last time I tested this it worked for HTML5 targets if I remember... and I have a live version where this works, but things may have changed in later version in some way. http://en.wikipedia.org/wiki/Same_origin_policy Test adding a crossdomain.xml to the root of your domain with this text. You would want to have it set to only work on your sites most likely. <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="master-only"/> <allow-access-from domain="*"/> <allow-http-request-headers-from domain="*" headers="*"/> </cross-domain-policy> | 
| 
 | ||
|  Test adding a crossdomain.xml to the root ... The crossdomain.xml file only works within Flash apps. | 
| 
 | ||
| I don't need html5 for my project, so I didn't try to fix. IOS works well. I use it like this: Global HTTPreq := New HTTPreqClass Class HTTPreqClass Implements IOnHttpRequestComplete Field get_req:HttpRequest, post_req:HttpRequest Method OnHttpRequestComplete:Void( req:HttpRequest ) If req=get_req Print "Http GET complete!" Else Print "Http POST complete!" Endif Print "Status=" + req.Status() oldPriceFile = req.ResponseText() End Method GetTxtFromWeb:Void(path:String) get_req = New HttpRequest( "GET", path, Self ) get_req.Send() End End HTTPreq.GetTxtFromWeb( "http://white-zebra.com/oldprice.txt" ) |