jQuery AJAX in Electron returns timeout


#1

So I have a working webapp and I need to make a desktop version. I’ve copied over all of the necessary files, and after installing a couple of extra packages, everything seems to be working correctly, with one (large) exception – all of my AJAX requests return a timeout error. Here’s an example of a simple request that just checks to make sure the service is running:

 $.ajax({
        url: serviceURI + "/GetServerTime",
        dataType: "jsonp",
        success: function (data) {
            //stuff
        },
        error: function (data) {

            if (data.status == '200') {
                //stuff
            } else {
                serviceUnavailable();
            }
        },
        timeout: 8000
    });

…and invariably I get to the last else statement, because I get back a timeout error. I have already placed “web-preferences”: { “web-security”: false} in the BrowserWindow, and that didn’t change anything. I know that node has a great package for this in request, but this entire webapp is already written using jQuery, since I would like the code to be portable between the web version and the desktop version, I would prefer to not have to rewrite all of my ajax requests.

Any ideas?


#2

It might be a silly question, but do you eventually get a response if you get rid of the timeout in your AJAX request?

As far as I’m aware, there’s no auto-timeout on the Electron side, and it’d be good to be sure that the problem is definitely on the Electron side and not on the server side.