无法加载资源:net :: ERR_CONNECTION_REFUSED Cordova android [英] Failed to load resource: net::ERR_CONNECTION_REFUSED Cordova android

查看:253
本文介绍了无法加载资源:net :: ERR_CONNECTION_REFUSED Cordova android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用cordova开发了一个android应用程序,我在调用api时遇到了以下问题,请帮我解决这个问题

i have developing one android application using cordova ,i have facing the following issue while calling api,kindly help me out this issue

Failed to load resource: net::ERR_CONNECTION_REFUSED(http://ip address:8080)


var uName = $('#UserName_input').val();
    var pwd = $('#Password_input').val();
    console.log("GetLogin function CallED~~~~~~~~~~~~~");
    console.log("GetLogin InternetStatus ~~~~~~~~~~~~~" + InternetStatus);
    console.log("GetLogin function uNam~~~~~~~~~~~~~" + uName);
    console.log("GetLogin function pwd ~~~~~~~~~~~~~" + pwd);
    if (InternetStatus == 'Online') {
        if (uName != "" && pwd != "") {
            //SpinnerDialog.show("Loading", "Please Wait...", true);
            $(".modal").show();
            /*---------->*/
            // alert("call before AJAX------>");
            debugger
            $.ajax({
                    url: baseURL + checkLogin,
                    type: 'POST',



                    data: {
                        'userName': uName,
                        'password': pwd
                    },
                    // ~~~~~~~~~~~~~~~~~  Basic autherntication ~~~~~~~~~~~~~~~~~~~~~~~~
                    /* beforeSend: function(xhr) {
                         xhr.setRequestHeader("Authorization", "Basic " + btoa("crewMobieAppAdmin" + ":" + "!uT#61@c#"));
                     },*/
                    success: function(result)
                        //we got the response
                        {

                            //debugger
                            console.log("message------>" + result.message + " \n status----->" + result.status);
                            //console.log(JSON.stringify(row));
                            if (result.status == "success") {

                                UserDatails(uName, result.tokenId);
                                ToastShow("Login Successfully.!!!", "#008000", "#FFFFFF");
                                USERNAME_localStorage_SET(uName);
                                PASSWORD_localStorage_SET(pwd);
                                BASEAUTH_localStorage_SET(result.tokenId);
                                PIN_localStorage_SET("");
                                SpinnerDialog.hide();
                                window.location.href = "home.html"
                                    //$(".modal").hide();

                            } else {
                                SpinnerDialog.hide();
                                ToastShow(result.message, "#FF0000", "#FFFFFF");
                                // $(".modal").hide();

                            }
                            //SpinnerDialog.hide();
                            // $(".modal").hide();
                        },
                    error: function(exception) {
                        ToastShow("Server not responding. Please try again after some time.!!!", "#FF0000", "#FFFFFF");
                        console.log('Exception:' + exception);
                        status = "failur"
                            // Hide spinner dialog
                            //SpinnerDialog.hide();
                            // $(".modal").hide();
                    }

                }) /*<----------*/
                // SpinnerDialog.hide();

        } else {
            ToastShow("Please enter valid username and password.!!!", "#FF0000", "#FFFFFF");
        }

    } else {
        ToastShow("please check your network connection and try again.!!!", "#FF0000", "#FFFFFF");
    }

推荐答案

这可能是版本兼容性问题.查看关于类似问题的答案

This could be version compatiiblity issue. Check out the answers on a similar issue here

否则,这可能是因为您已阻止应用程序中的API URL.在config.xml中设置以下值

Else, this could be because you have blocked the API URLs in your application. Set the following values in your config.xml

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

注意:这不是建议的生产设置.如果此解决方案适合您,请考虑对URL进行微调.有关更多详细信息,请参考将URL列入白名单-Cordova文档有关如何配置它的信息.

Note: This is not a recommended setting for production. If this solution works for you consider fine-tuning your URLs. Refer Whitelisting URLS - Cordova Documentation for more details on how you can configure this.

这篇关于无法加载资源:net :: ERR_CONNECTION_REFUSED Cordova android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆