How do I load json from ajax request

Get help using Construct 2

Post » Sat Feb 21, 2015 1:47 am

@kaiko Yah.. I see two problems..

1) You defined the tag for the AJAX request as "get login". But on the event listener you are looking for on "login".. those key names have to be the same or your event listener wont detect when the AJAX response comes back.

2) Your domain does not appear to allow cross domain AJAX requests. IE the AJAX request is originating from "http://YourTestIP:50000" but its being sent to "http://dev.canvaramanager.com". You need to allow crosss domain AJAX requests by adding a PHP header tag or the AJAX request is blocked by your server. This is standard as it is meant to protect the server from outside attacks.

You need to add this to your PHP file. Caution this is dangerous as it opens up to potential malicious attacks from out side domains but is needed for testing
Code: Select all
header('Access-Control-Allow-Origin: *');
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Sat Feb 21, 2015 10:08 pm

@troublesum:how to debug your plugin?
B
9
S
2
Posts: 76
Reputation: 709

Post » Sat Feb 21, 2015 10:22 pm

@troublesum: never mind i got it working now, thanks your plugin rocks.
B
9
S
2
Posts: 76
Reputation: 709

Post » Sat Feb 21, 2015 11:01 pm

@kaiko .. Awesome!! ... Glad it worked for you.

Yah the debug feature needs to be enabled. I did that because sometimes the storage can be pretty large so you can enable to view the whole thing in the debug view or just a certain table or list.

To enable it, call one of these action on start of layout.
deb.png


Let me know if you have any questions :)
You do not have the required permissions to view the files attached to this post.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Sun Feb 22, 2015 8:04 am

@troublesum: how can we get your plugin to be part of C2 default package?
B
9
S
2
Posts: 76
Reputation: 709

Post » Thu Feb 26, 2015 4:14 am

@troublesome
Essential plugin for anyone who wants to use Ajax.

One small issue, for some reason, it was generating an error for me, adding a closing </i> to edittime.js line 160 fixed it.

eg
<b>Merge <i>Table(s) AsJSON</b>

changed too
<b>Merge <i>Table(s) AsJSON</i></b>
B
7
S
1
Posts: 33
Reputation: 501

Post » Fri Feb 27, 2015 10:11 pm

@bentwonk - Thank you.. I fixed it in mine. Also because you guys seem to like it so much I created a forum post for this plugin to make it available. Thank you for the kind words :)
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Sun Nov 29, 2015 3:56 pm

$troublesum hi im using your storage plugin and its been working great so far however it cannot seem to parse this json utf8 japanese string:
"{\"win\":\"勝利\",\"bet\":\"賭け\",\"balance\":\"バランス\",\"bmenu\":\"メニュー\",\"paytable\":\"ペイテーブル\",\"bet_one\":\"ベット1\",\"bet_max\":\"ベットマックス\",\"spin\":\"スピン\"}"

when i debug the plugin in c2 i see that it sliced the string up in parts for each character.
any idea on how to solve my problem?
is there a new version of plugin etc?
B
9
S
2
Posts: 76
Reputation: 709

Previous

Return to How do I....?

Who is online

Users browsing this forum: batto and 22 guests