質問

I am trying to deploy a web app to android via Trigger.io. Although the app manages to load initially, I run the application with a local server, but i received an error

[FORGE] '[getInfo] {"message":"Request timed out","type":"EXPECTED_FAILURE"}'

here the js :

forge.enableDebug();

$(function(){
    getInfo();
});

        
        function populate(w) {
            
        alert(w.success);
        
        };
        

function getInfo() {


    forge.request.ajax({
        url: "http://localhost/mobile/src/post.php",
        dataType: "json",
        success: function (data) {
            forge.logging.info("[getInfo] success");
           
        },
        error: function (error) {
            forge.logging.error("[getInfo] " + JSON.stringify(error));
        }
    });
};

and the post.php :

<?php
{"success":0,"error":0} 
?>

add permissions :

"modules": {
        "request": {
            "version": "2.3",
            "config": {
                "permissions": [
                    "http://localhost/mobile/src/*",
                    "http://*/*",
                    "https://*/*"
                ]
            }
        }
    }
役に立ちましたか?

解決

Are you trying to run this via an emulator or on the device?

Also are you able to access localhost from the emulator or device?

I am taking a guess here but I'm thinking that your device cant reach localhost because its an internal server not broadcasting on port 80, even if it was you would not be able to connect via localhost, if your test server is on local host and open for web traffic then try connecting to the IP I would assume this would work if its open to the net.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top