XMLHttpRequest in NodeWebkit, status = 0

This works in Chrome when doing it on my local server. However, when I transfer over to NodeWebkit, it fails with status === 0.

function ReadText(filename) {
    var txtFile = new XMLHttpRequest();
    txtFile.open("GET", filename, true);
    txtFile.onreadystatechange = function () {
        if (txtFile.readyState === 4) // Makes sure the document is ready to parse.
            if (txtFile.status === 200) // Makes sure it's found the file.
                g_FileLoadContents = txtFile.responseText;

g_FileLoadContents is a global and ReadFile is a function that does some work on g_FileLoadContents... but it does not get that far in the NodeWebkit (Again, I'll stress all is ok in Chrome when on my local server).

In NodeWebkit I watch txtFile.readyState change up to 4, but then txtFile.status is 0.

Why is the status 0? When I use the nodeWebkit, should I just let the status be 0 in my code above?

I hope someone can explain, as I am very confused.


HTTP status codes are returned by webservers. Presumedly your local server returns 200 when you're doing this in Chrome, but node-webkit just returns 0 (Unknown?).

Normally reading local files is restricted though. Does the code above actually produce the file contents? Even so, if you're trying to read files in node-webkit I would suggest using the node fs module to access the filesystem directly.

Need Your Help

Java WS file upload service

soap wsdl wsdl2java java-ws

I am currently working on a Java Web Service project. It is deployed on an Apache Tomcat 7 server and I need to provide a service for uploading files to the server. Also, the web service should be

App code in published asp.net app

c# asp.net build

I published my asp.net app using the basic capability (publish to disk). Now I look at the published content and it contains .cs files. Is this correct? I did right-click 'convert to web applicatio...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.