Application Error - The connection to the server was unsuccessful.
2017-03-30 17:21
323 查看
最近用phonegap封装前端页面做的项目时,遇到一个问题,分享一下,希望可以帮到有同样问题的朋友。 在启动应用时会报错:Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html) 导致这个错误的原因是: 在安卓load页面时,页面需要加载的内容没有加载完。所以需要增加超时时间,或加一个过渡页来避免这个问题。 方案如下: 1.在load页面时,先load一个空的页面,当页面load完成时,再加载现在的index.html,步骤如下: 1)将你的"index.html"改名为"main.html"; 2)创建一个新的"index.html",把下面的内容放到"index.html"中, <script type="text/javascript"> window.location="./main.html"; </script>. 2.将LoadUrlTimeoutValue设置为50或60秒,默认是20秒(此方案只能减少这个错误,无法从源头解决问题), 在config.xml中增加下面这行: <preference name="loadUrlTimeoutValue" value="50000" /> 注:第二种方案只会减少产生这种错误,但不会从根本上避免这个问题,所以建议使用第一种方法, 第二种可以作为辅助手段。 如果是在中间弹出的这个错误框,可能是由以下原因导致的: The problem is likely due to the speed of the emulator so the network is too slow complete the communication in a timely fashion. This can be due to: as you said you made some UI modifications, may be the size of images are high) 2.Your script may have a infinite or long loop, so that it takes too much of time to load. 3.You will be using too much of scripts (jQuery, iscroll, etc etc.. more number of plugins or scripts ) 超时引起的问题可以增加超时时间,增加loadUrlTimeoutValue的值; 如果是由图片引起的,建议可以通过降低图片的色位,大小等。 想起之前架构师的一句话,分享给大家:代码是最不会骗人的,遇到的问题,就去查代码吧。
相关文章推荐
- Android App启动错误的问题(connection to the server was unsuccessful)
- 处理phonegap(cordova) application error the connection to the server was unsuccessful的错误
- [置顶] Application Error - The connection to the server was unsuccessful.
- Application Error - The connection to the server was unsuccessful.
- Ionic-Android平台项目调试时出错:The connection to the server was unsuccessful
- [Android_Bug]处理PhoneGap Application Error: "The connection to the server was unsuccessful.(file:///android_asset/www/index.html)"的错误
- 解决ionic3 android 运行出现Application Error - The connection to the server was unsuccessful
- PhoneGap开发出现 Application Error - The connection to the server was unsuccessful.
- the connection to the VMware USB Arbitration Service was unsuccessful.Please check the status of this service in the Microsogt M
- VMware启动错误信息: The connection to the VMware USB Arbitration Service was unsuccessful
- the connection to the VMware USB Arbitration Service was unsuccessful.Please check the status of thi
- VMware启动错误信息: The connection to the VMware USB Arbitration Service was unsuccessful
- 【错误】:Could not open JDBC Connection for transaction; nested exception is: Communications link failure;The last packet sent successfully to the server was 1 milliseconds ago
- Exception : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server
- Firefox: Connection Interrupted | The connection to the server was reset while the page was loading
- com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection......
- 解决 anyconnect was net able to establish a connection to the specified secure gateway
- Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the server requires
- the module '*' was loaded but the call to DllRegisterServer failed with error 0x80004005
- how to set up the remote accout who to connection and management mysql server