Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17754] Android: Throw an event after each AJAX call inside a webview

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-01-08T23:27:59.000+0000
Affected Version/sRelease 3.3.0, Release 3.4.0
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsmodule_webview, qe-manualtest
ReporterMauro Parra-Miranda
AssigneeAshraf Abu
Created2014-09-24T19:28:11.000+0000
Updated2015-05-29T02:53:09.000+0000

Description

Problem Description

The user wants to sync a ecommerce's cart inside a webview with a view showing the number of items in the cart in the app. Therefore, he wants to have an event in the webview that throws an event when the cart is updated via AJAX.

Extra information

We did some research, and we found some info that could be useful. http://developer.android.com/reference/android/webkit/WebViewClient.html And this method public WebResourceResponse shouldInterceptRequest (WebView view, String url) StackOverFlow mentioned that method as a way to catch ajax calls: http://stackoverflow.com/questions/3941969/android-intercept-ajax-call-from-webview

Comments

  1. Ashraf Abu 2014-12-30

    PR: https://github.com/appcelerator/titanium_mobile/pull/6528 Do test it out with the site with the AJAX call. onLoadResource is available on all Android API level. shouldInterceptRequest is only available on API level 11 aka Honeycomb devices. If used on Gingerbread (level 10), it won't be available.
       var win = Ti.UI.createWindow();
       //Replace weblink here with ajax site
       var webview = Titanium.UI.createWebView({url:'http://ajaxtoolbox.com/request/examples.php'});
       
       webview.addEventListener('onLoadResource', function(e) {
       Ti.API.info("onLoadResource Event Listener "+ e.url);
       });
       
       win.add(webview);
       win.open();
       
  2. Kajenthiran Velummaylum 2015-02-16

    Tested onLoadResource event on WebView. Titanium SDK: 4.0.0.v20150205163226 Appc-Studio: 4.0.0.201502111458 Titanium CLI: 3.6.0-dev Alloy : 1.5.1 GA OS: OSX 10.10.1 Device : Galaxy S5 (v4.4.2)

JSON Source