How do I dynamicly load project files with AJAX

0 favourites
  • 8 posts
From the Asset Store
With this template you can create your own archer game and customize it however you want.
  • Hi there,

    I have a XML File with all the paths to my levels. The pathes to the Levels are paths in the ProjectFiles folder.

    [attachment=0:1ffmo5p1][/attachment:1ffmo5p1]

    I want to load my level variabl. So if a user clicks on Level 1, I want to load the file "Level1" in my ProjectFiles Folder.

    [attachment=1:1ffmo5p1][/attachment:1ffmo5p1]

    As Ashley wrote in this tutorial:

    [quote:1ffmo5p1]You can also allow yourself to change or add new levels after the game is published, without re-uploading the entire game. For example if you load a list of available levels from an XML file, you only need to upload or change a few .json files then edit the .xml file in order to add or update levels.

    But how do I load my Levels from various XML project files if I can't acces them variabl? Do i have to put all my Levels in one single XML file? Are there any known issues with big XML file (arround some MB (like 2 or 3))

    Thanks for your help

    PS: sorry zhat my english is not se yellow from se egg :/

    Best regards Beni

  • "WorldOverview" is not a valid XML document. The action you are using expects an XML document starting with the usual "<?xml ...". You can pass any variable that is a valid XML document. You might need to AJAX request a project file first.

  • Sorry maybe I was not clear what i wanted, I did load my XML document with all the pathes, I now want to load each document with the Data inside. The data is in my example a MapData. But with the AJAX Plugin i can only load files if prerender choose which File this should be. I cannot load these Files on runtime dynamcly. So this would mean i can't change after release a path in my XML File and a map.

    [attachment=0:1o3xvs7l][/attachment:1o3xvs7l]

    As I do it now I'm not satisfied. I load a php file on a server which gives me all my files in directory on the Server. But that would mean that the player has to be always online, and my game is just not that type of game which has to be alwaysonline :/

    Is there any way to do this "offline" (which means download once like in your tutorial explained)

    Thanks for your help

  • I believe project files are exported to a single common folder, so your logic will probably need some fixing.

    Anyhow, if you want to load at run time your XML, use the AJAX object's "Request project file" action. Then, on AJAX completed, Load XML -> AJAX.LastData

  • You can also use AJAX > Request URL :: Then put in the actual URL to the XML document. Like: http://192.168.0.1/subfolder1/subfolder ... erview.xml

    Then use AJAX.LastData to read the response.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Will this work with the lokal ip 127.0.0.1? Or how does this end up after i export this as a html5 website or on a phone?

  • All the project files are actually exported flat, to the same folder - the project structure is lost on export. So for example you'd AJAX request just "Level3.xml", without any subfolder.

  • Thanks so much, you helped me a lot

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)