带有Web服务的Cordova Android App

时间:2016-07-07 15:39:37

标签: android web-services cordova

我开发了一个带有与WebService通信的cordova的应用程序。它适用于Ios,但如果我尝试在Android上使用它,首先是WebService调用,它不起作用......

这里是我的代码:

doLogin: function (user, password, successCallback, failCallback) {
                    jApp.gui.showWait();
                    var parametri = "NomeUtente=" + user + "&Password=" + password;
                    $.ajax({
                        url: serviceUrl + "Login.ashx?" + parametri,
                        dataType: "jsonp",
                        dataFilter: null,
                        async: true,
                        success: <-- I think it stops here
                            function (r) {
                            jApp.gui.hideWait();
                            if (r.Success)
                            {
                                //salvo le credenziali su file
                                var strLogin = '{"user":"' + user + '","password":"' + password + '"}';
                                window.resolveLocalFileSystemURL(pathApp, function (dir) {
                                    dir.getFile("login.json", {create: true}, function (file) {
                                        file.createWriter(function (fileWriter) {
                                            fileWriter.seek(fileWriter.length);
                                            var blob = new Blob([strLogin], { type: 'text/plain' });
                                                fileWriter.onwriteend = function (evt) {
                                                successCallback(r);
                                            }
                                            fileWriter.write(blob);

                                        }, failCallback);
                                    });
                                });
                                //TODO: salvarsi user e pwd?
                            }
                            else
                            {
                                alert(r.ErrorMessage);
                            }
                        },
                        error: function (e) {
                            jApp.gui.hideWait();
                            alert("errore");
                        }
                    });

谢谢

0 个答案:

没有答案