i am currently using the xml plugin to load my variables when using ajax requests and it works fine but but the xml data is much larger in size so since im aiming for the mobile market i want to minimize the data transfer size.ad having a json plugin that works exactly like the xml plugin would help to minimize the data size.
is there a json plugin for this?
or is there maybe a usable workaround?
Ashley: you wrote earlier that this feature was planned but no ETA, do you have an update on this task?
https : // www scirra com /forum/plugin-json-import-export-generate-edit-inspect_t100042
thanks, tried but this plugin loads json from an external file, i need to parse the Json data from AJax.lastdata
Example capx usage r195
Develop games in your browser. Powerful, performant & highly capable.
uhm ok, i tried your plugin,but in your example I cannot see how you acquire external data?
from an ajax request the complete dataset is in ajax.lastdata and i neeed to get it into some form of function so i can assign its values to variables see pic below.
kaiko you can take the Ajax.LastData and load it into the Storage object using the Merge Table action. When you're done you can dump the JSON string to text object to see it.
The storage object is 3 dimensional so if your JSON object is one dimensional it will create top level names of "default".
Think of it as a C2 Array that works more like a C2 Dictionary
ive tried this but storage doesnt print anything in text ,and when i debug i cant see that storage gets any data at all.
can you see where what im doing wrong?
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
troublesum:how to debug your plugin?
troublesum: never mind i got it working now, thanks your plugin rocks.
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.
Let me know if you have any questions
troublesum: how can we get your plugin to be part of C2 default package?