Hello i have downloaded the demo of cosntruc, i would like to show a text, from an url: mattepainting.be/index.txt inside the textbox.
How to do that?
thanks
best to look through the basic tutorial
scirra.com/tutorials/37/beginners-guide-to-construct-2
Actually, the beginner tutorial won't be any help here...
You need to use the AJAX object in C2 to request the file as detailed here
(It won't work if you request it from another domain)
Thanks lemo :D
MMhh i have tried... actualy it look like this but its not working :s
<img src="http://img22.imageshack.us/img22/323/ajax01.jpg" border="0" />
here its the link of my app: mattepainting.be/test/run.html
nothing happens, that don't show the text from index.html
Don't use AJAX.LastData as a tag (:
And also, I'm not sure that the On created is triggered if the object already exists in the layout
Try
On start of layout: [ul] [li]> request "http://mattepainting.be/index.txt" tag "aSimpleString"[/li] [/ul]+AJAX On "aSimpleString" completed [ul] [li]> Textbox: set text to AJAX.LastData
Also by renaming index.html to run.html you break a reference in the offline.appcache manifest.
You should either keep the index.html name or modify it inside the manifest.
Ok i have done like you told me but :s result don't work :s
<img src="http://img809.imageshack.us/img809/323/ajax01.jpg" border="0">
and the test: http://mattepainting.be/test/index.html
Can someone help please?? i think the AJAX don't work.
So i have made everything, but the ajax don't want to show the link by requesting his url.
i don't know what to do, i want just to load an external text file in the text box.
In the console you can read:
XMLHttpRequest cannot load http://www.mattepainting.be/index.txt. Origin http://mattepainting.be is not allowed by Access-Control-Allow-Origin
try to put the index.text in the same folder as your "game" maybe (: (and change the url queried accordingly
The other solution would be to create a .htaccess with the proper things in it to set Access-Control-Allow-Origin properly. But it's not a good thing security-wise.
no that change nothing, that don't work at all <img src="smileys/smiley19.gif" border="0" align="middle" />
Develop games in your browser. Powerful, performant & highly capable.
This works:
http://www.mattepainting.be/test/index.html
There's a difference between http://mattepainting.be and http://www.mattepainting.be. You can't make AJAX requests from mattepainting.be to the www subdomain. You should make your requests relative like
AJAX request "index.txt"
or "../index.txt"
ahhh lool thanks :D solved :D