... load a file?

0 favourites
  • 10 posts
From the Asset Store
Excel2JSON
$1.20 USD
60% off
Convert multiple Excel files into JSON files and import them into construct3.
  • Okay, I'm stumped. No matter what I do, nothing works.

    I tried these:

    jQuery.ajax({
                type:"GET",
                url:this.file,
                dataType:"xml",
                success:function(xml){alert(xml);}
                }); 
    
    jQuery.get("test.xml",function(xml){alert(xml);});
    
    instanceProto.loadFile = function(file)
        {
            var request = null;
            if (window.XMLHttpRequest) 
            {
                request = new XMLHttpRequest;
            }
            else
            {
                alert("XMLHttpRequest is not supported by your browser.");
            };
            
            if(!(request === null))
            {
                request.open("GET", file, true);
                request.onreadystatechange = function()
                {
                    if (request.readyState == 4 /* complete */) {
                        if (request.status == 200 || request.status == 304) {
                        alert('Transfer complete. XML data updated.');
                        this.data = request.responseText;
                        this.ready = true;
                    }
                    else {
                        alert('An error occurred. Old XML data kept.');
                        this.ready = true;
                    };
                };
                request.send();
                this.ready = false;
                };
            }
            
        }
    

    But nothing works. No data is loaded, hell, AJAX doesn't even complete the task. I don't even get the error popups when AJAX would fail to load a file.

    I've tried all these locally as well as exported to dropbox.

    So how the heck do you load a local (to the index.html) file? Because a lot hinges on this functionality.

  • L? bump. Any ideas? <img src="smileys/smiley3.gif" border="0" align="middle" />

  • maybe its a crossdomain issue, but then its strange that you dont get any alert

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can't be crossdomain issue if the file is in the same folder as project.

  • I'm really not sure, and this might be a dumb suggestion/question but shouldn't the jquery.get line be placed in instanceProto.onCreate ?

  • That's where I pasted all that code from.

  • Then maybe instanceProto.loadFile should be out of that function, placed earlier/before onCreate. You call it in onCreate.

  • Oh, I mean I pasted the GET from onCreate, the instanceProto.loadFile is called from onCreate. Sorry I wasn't clearer. I'm not that dumb :)

  • Sorry I doubted you.

    I'm afraid I can't be of any help on this.

    Maybe rexrainbow, R0J0hound or Ashley might help (if they don't mind too much the alerting ^^)

  • i know.

    the request.send(); needs to be moved out one level of brackets..

    you had it in the function which is only called when you get successful response but you wont get a response as you never send in the first place.

    try moving it down a few lines

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