angular.js - The angularjs framework used in WeChat public account development, how to monitor network status in real time and prevent $http requests when the network is disconnected
PHPz
PHPz 2017-05-15 17:10:15
0
1
1509

Use angular to develop public accounts and use the $http service to access data. However, in the WeChat test, when the network is disconnected, the $http request is still executed and the error page jumps ( Because the interceptor is set up, when $http does not respond or the response fails, my custom interceptor will cause the page to jump. Go to a custom error page ) instead of prompting: wifi and mobile data disconnected , when the request is a normal http://www.baidu. com link, WeChat can prompt: WiFi and mobile data have been disconnected. How can I intercept the $http request and prompt correctly after the network is disconnected? Thank you

PHPz
PHPz

学习是最好的投资!

reply all(1)
習慣沉默

You can prompt based on the status code returned by the http request, such as 404, 500, etc. to switch to different prompt pages

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template