How do I can read a external JSON or XML file?

Get help using Construct 2

Post » Fri Feb 20, 2015 9:51 am

I have seen more christmas then you had hot dinners ..

:lol: :lol: :mrgreen:

My opinion is done and I want change my opinion that easy. I have seen and experience with both kind of "characters", but to 99% it's: "Do it, this is a forum. I command it, community, make me the new Zuckerberg"

But I prefer to close this thread or start a new one somewhere else about "ethic".
B
15
S
4
Posts: 77
Reputation: 1,030

Post » Fri Feb 20, 2015 3:47 pm

I have seen several people tell information seekers that they can't expect someone to 'do it for them' - You are giving your opinion and expecting everyone else to follow along - some people might well be quite happy to throw a little example capx together. This is a community forum, the OP is quite within reason to ask if someone would be willing to do that for them. If you don't want to do that then don't.

Shiva - I too have seen many Christmases. Your age and mine is irrelevant - You don't get extra kudos for being old. :D
Image
B
14
S
3
G
1
Posts: 61
Reputation: 993

Post » Fri Feb 20, 2015 4:00 pm

I did not ask for one and never will
B
212
S
28
G
14
Posts: 1,865
Reputation: 36,874

Post » Fri Feb 20, 2015 4:01 pm

Jermfire wrote:I think what he is having trouble with, is getting the game to read a json or xml file from an external server(url). An issue I was having as well at one point. By default, browsers are set to block those request, so you have to give that permission manually.


I think this is what your after? Copied from tutorial.

Making AJAX requests cross-domain or in preview
By default, browsers block AJAX requests across domains. This means, for example, a game on scirra.com can request other pages on scirra.com, but cannot request pages on facebook.com. This is an important security feature of web browsers (it is not specific to Construct 2 or its AJAX object).

Also, when previewing in Construct 2 the game runs on localhost. This counts as a different domain to the rest of the internet, so typically AJAX requests to any web page will fail during preview, unless the server explicitly allows cross-domain requests.

*** (this part is the trouble. Lack of explanation here down)****

If you want AJAX requests to your server to work from any domain, or in preview, you can configure it to send the following HTTP header:

Access-Control-Allow-Origin: *

This will enable AJAX requests from any domain, but you should still be aware of the possible security implications of this. For more information on cross-domain requests see HTTP access control on MDN.


Thx so much for all!!
B
5
Posts: 14
Reputation: 253

Post » Fri Feb 20, 2015 4:03 pm

Lordshiva1948 wrote:I did not ask for one and never will


I did not say that you did. There is nothing wrong with asking though.
Image
B
14
S
3
G
1
Posts: 61
Reputation: 993

Post » Fri Feb 20, 2015 6:31 pm

that's true but one must understand one has already given one answer therefore one must know one must do. I gave him something to read I did not asked him to download anything
B
212
S
28
G
14
Posts: 1,865
Reputation: 36,874

Post » Sat Feb 21, 2015 4:46 am

Lordshiva1948 wrote:that's true but one must understand one has already given one answer therefore one must know one must do. I gave him something to read I did not asked him to download anything


If you notice, He responded to my answer positively in an understanding way. I didn't do the work for him. I didn't give him anything, but point out a simple location that actually has to be further researched if you don't know anything about configuring http headers. So He is still doing the work himself, but is now guided in the right direction.

You still seem to misunderstand his post. He wasn't referring to you giving him something to download.
He is saying he doesn't want to download the file in his original question. He wants to know how to link to it.

Do you, or do you not know how to get C2 to read a file from an external website without downloading?

That is the whole question. Yes, we all including op know how to add an xml from our harddrive into the "files" folder and get Ajax to read from it. The original tutorial that everybody always links to doesn't address op's problem directly.

What the question is: How can I get Ajax to call up Http://www.somewebsite.com/folder/iwantthis.xml and read from it.

Did I break it down enough?
B
9
S
2
Posts: 80
Reputation: 854

Post » Sat Feb 21, 2015 4:52 am

Lordshiva1948 wrote:I have seen more christmas then you had hot dinners Jermfire.


As far as I can remember, I have had a hot dinner, every day of my life. Wait. 365 days in a year so...
365 x 29 = 10,585. So you've seen over 10,585 Christmases?? Dude. Are you Moses?

lol jk. had to pick at ya on that one. :P
B
9
S
2
Posts: 80
Reputation: 854

Post » Sat Feb 21, 2015 9:15 am

This is gone way out of hands. Let me put truce and say ok boys you win and this oldman lost. Will that satisfy you if yes then so be it. No more on this subject. I am not shamed to say I have put end to it. God Bless you all
B
212
S
28
G
14
Posts: 1,865
Reputation: 36,874

Post » Thu Feb 26, 2015 12:12 am

This is exactly the problem I am having trying to retrieve an XML file from my website. I can find no example of how to follow this instruction.
----------------------------------- from the manual -----------------------------------------------
If you want AJAX requests to your server to work from any domain, or in preview, you can configure it to send the following HTTP header:

Access-Control-Allow-Origin: *
--------------------------------------
I tried sending a header using the AJAX send header action with the following values

Header: "Access-Control-Allow-Origin:" Value: "*"

Then followed it with an AJAX request url action. No luck. any suggestions?
B
5
Posts: 2
Reputation: 929

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: wiredcleric and 11 guests