문제

I'm building a hybrid iOS App. Some UIs are drawn by HTML5 in a UIWebView. The HTML5, Javascript, and CSS are all deployed on the server and the app loads the HTML5 page by sending a URL request.

If the app needs to load some date from server, the HTTP request is sent by Javascript in and HTML5 page instead of being sent by a native Objective C code. My question is: How can I cancel the HTTP request that has been sent by Javascript, for instance, if the view controller calls popToViewController, we want to cancel the unfinished http request?

If the HTTP request sent by native code, we can cancel it by calling the "cancel" method of NSURLConnection, but I have no idea how to cancel the HTTP request that is sent by the Javascript code.

Thanks in advance!

도움이 되었습니까?

해결책 2

if you are using jquery you need to use request.abort(); but, its only works inside the js on the same script that runing. and remember that overtime you are sending a request via your app - you you are loading a new web page and a new js, so if you trying to do it from the app - i do not think its possible.

다른 팁

If you're using an XMLHttpRequest object, you can call .abort().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top