0 Favourites

How do I dynamicly load project files with AJAX

  • 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.

  • 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?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
144 24,226
ffman22's avatar
ffman22
Unread hot topic
99 10,159
karshinkoff's avatar
karshinkoff
Unread hot topic Locked topic
112 7,124
Ashley's avatar
Ashley Construct Team Founder