$ .ajax调用不会在Android设备上通过

时间:2015-08-11 15:52:09

标签: android jquery ajax cordova visual-studio-cordova

Javascript代码:

                var googledocsurl = "https://docs.google.com/viewer?url=";
                $.ajax({
                    url: window.localStorage.getItem('basePath') + 'pdf/GetPdfUrls',
                    type: "GET",
                    data: { id: window.localStorage.getItem('userid') },
                    dataType: "json",
                    beforeSend: function () { $.mobile.loading('show'); },
                    success: function (returnValue) {
                        for (var i = 0; i < returnValue.length; i++) {
                            $('#pdfList').append("<li><a onclick=\"window.open('" + googledocsurl + window.localStorage.getItem('basePath') + returnValue[i].pdfUri + "\', '_blank', 'location=yes')\">" + returnValue[i].PdfCreationDate + "</a></li>")
                        }
                    },
                    error: function () {

                    },
                    complete: function () { $.mobile.loading('hide'); },
                })

如果我在模拟器上尝试这个ajax调用并且ripply它没有问题但是就像我在我的Android设备上尝试它一样,它工作了1/50次,它有点不一致,这使得它很难修复或理解

我在Visual Studio中可以看到的错误

Failed to load resource: net::ERR_NAME_NOT_RESOLVED
GetPdfUrls(0,0)

如果我点击“GetPdfUrls(0,0)”我可以看到响应并且它填充了数据但是由于某种原因这给了我和错误但是我可以看到它对我来说没问题(特别是感觉它在我尝试的50次中有1次工作)

回应:

[{"pdfUri":"Image/GetPdf/8259ff54-6cd2-48dd-a0dc-d39b255e9bad","PdfCreationDate":"2014-12-08"},{"pdfUri":"Image/GetPdf/f05ff375-45e2-429b-a8fc-2c9d660df263","PdfCreationDate":"2014-12-08"},{"pdfUri":"Image/GetPdf/211feab8-9715-4942-bf8c-f7e95188c987","PdfCreationDate":"2014-12-08"},{"pdfUri":"Image/GetPdf/6ded622b-2d3e-4151-8be3-01070d1b9d69","PdfCreationDate":"2014-12-08"},{"pdfUri":"Image/GetPdf/f34adfa9-7bbf-4db9-b7ee-92fd619b0dc0","PdfCreationDate":"2014-12-08"},{"pdfUri":"Image/GetPdf/b6e5e56c-68d3-4662-a00e-b11dc09bfd9a","PdfCreationDate":"2014-12-08"},{"pdfUri":"Image/GetPdf/cc633e61-adcd-414d-bfc7-d09a30e05b01","PdfCreationDate":"2014-12-15"}]

如果您需要更多信息,请尽量提供! 提前感谢所有帮助

1 个答案:

答案 0 :(得分:2)

我现在感觉不傻......

手机这样的接缝在没有连接到wifi网络时没有任何互联网,并且接缝随机丢失与路由器的连接并连接到具有相同信号的另一个wifi网络(没有互联网连接)强度,然后随机改变(猜测它采用具有最佳信号强度的已知网络)。

我很幸运,我看到了logcat日志,看到这种变化发生了另外一种情况,我会被困住一段时间:/

无论如何,谢谢大家的帮助!