[SOLVED] Loading an external XML file through AJAX Plugin

0 favourites
  • 6 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • Hey, hello everybody !

    I'm using the FREE version of Construct 2. (I tested both last STABLE and last BETA versions).

    It seems my event code not working as expected!

    By the way I read how doing it on page which I can't show you the links since the forum don't permit me to add them

    the official manual page for loading an XML file through an AJAX call of the AJAX Plugin.

    and the tutorial page for know how using the XML Plugin and then make node get/set through the XPATH Syntax.

    Nothing seems working for me, all I got is 404 NOT FOUND when debugging the AJAX result content..

    My XML file must be dynamically loaded through RUNTIME (and so it's not good to include it at EDITTIME in Included Files to my Construct 2 project.

    I tested also with an other XML file instead mine, so, aswell this XML code:

    <?xml version='1.0' ?>
    	<chapter1>
    		<hint id='intro1'>Good morning Mr Bond, how did you sleep ?</hint>
    		<hint id='intro2'>I have prepared your breakfast for you</hint>
    		<hint id='intro3'>Come find me when you're finished</hint>
    	</chapter1>
    [/code:ux1aky2p]
    
    [i]seems not loaded through my project.[/i]
    
    [b][u]This is like my OBJECTS are:[/u][/b]
    
    I have three objects:
    [ul]
    [li]  object type: "AJAX Plugin", named as: utility_AJAX[/li]
    [li]  object type: "XML Plugin", named as: utility_XMLDoor[/li]
    [li]  object type: "MultilineBox Plugin", named as: MultilineBox (object found at: )[/li][/ul]
    
    [b][u]This is like my EVENTS are:[/u][/b]
    [code:ux1aky2p]
    CONDITION: (SYSTEM) -> On start of layout
    ACTION 1: [utility_AJAX] Set request header "Access-Control-Allow-Origin" to "http://localhost:50000/"
    ACTION 2: [utility_AJAX] Override MIME Type with ".xml files: text/xml"
    ACTION 3: [utility_AJAX] Request "pop.xml" (tag: "tmp")
    
     NOTE: don't work even if I don't add Action 1, 2  to action event's line)
    
    CONDITION: [utility_AJAX] -> On "tmp" completed
    ACTION 1: [utility_XMLDoor] Load XML Document from string utility_AJAX.LastData
    ACTION 2: [MultilineBox] Set text to utility_AJAX.LastData
    [/code:ux1aky2p]
    
    My pop.xml (test file) is located in : "%ROOT_Construct2_InstallationDirectory%\mesProjets\dynacoGame\pop.xml"
    
    So... Is it impossible to what I want achieve in FREE Version (if yes, I will buy the Personal Edition), if not, what I'm doing wrong?
    
    Also, is it possible to load my XML file if I locate in there path: "%ROOT_Construct2_InstallationDirectory%\mesProjets\dynacoGame\_gameRes\Level1\pop.xml" ?
    
    THANKS for all answer, since I'm just stuck in a way I can't unstuck me myself..
    
    ps: I tested each times in Construct 2 HTML5 preview mode (and both Chrome or Firefox or even IE)
  • I want add that with the Node-Webkit preview, I get the 404 error too.. So..

    Please, tell me...

    Is will working in a Personal purchased version ?

  • Okay.. just went and built a capx that loads a local xml file using node-webkit.

    this is my first time doing this sort of thing.

    [attachment=0:3sx149dv][/attachment:3sx149dv]

    You'll need to export the project to node-webkit and put the document.xml file in the app's folder.

    Then run the program and it'll load it. It won't work in preview.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks a bunch for your help !

    So...

    Ok like I said, (and I'm afraid to discover that), the free version is limited to do that (Exporting a Node-Webkit project), but the problem is that the PREVIEW MODE won't work with external local loaded files through both Paid Construct 2 version/Free Construct 2 version.

    So my question is now reallocated to Ashley (and any Construct 2 software developpers):

    Why we can't locally load files in Preview Mode in Node-Webkit ??

    * Is it a thing already submitted as a bug?

    ** When this will be fixed ?

    Thanks for answer.

  • [quote:10f9gv3j]Why we can't locally load files in Preview Mode in Node-Webkit ??

    We can though. In node-webkit preview if you use "document.xml" as the file it will look here:

    "http://localhost:50000/document.xml"

    If you want to get the file from the same folder as the capx you need to type it in explicitly:

    "C:\Users\rojo\Documents\c2projects\document.xml"

    And to make it work in preview or in export you could use a global like this:

    global text AppPath = "C:\Users\rojo\Documents\c2projects\"

    Start of layout

    System: [NEGATE] is in preview

    --- set AppPath to NodeWebkit.AppFolder

    And then request any files with:

    AppPath & "document.xml"

  • R0j0hound:

    I want thank you carefully, you unstucked me!

    AND even given me an ability to have an autoswitchable way to debug the game !

    Must say, I was knowing that the "NodeWebkit.AppFolder" was fixed to the path where Node-Webkit for Construct 2 has been installed.

    But even by playing with "..\" strings for goback in directory it won't work!

    So, with your method all work as intended an like a charm !!

    THANK YOU CAREFULLY !

    (Can't upvote your answer due to my not enough Reputation points on the forum, but yes, will do that in one day !)

    Also, now I'm unstucked with this behavior, I can continue to design my game, next way is going to give to my game an ability to multiload EVERY XML files through a precises folders (and subfolders too), do you know a Plugin able to doing that ?

    Or way better a CapX sample for learn how?

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