javascript - MonoTouch - Can I call ShouldStartLoad with AJAX? -


first of all, want thank miguel.de.icaza this answer! helped lot! - here's big but, here's our problem. in uiwebview start "little" javascript app, created senchatouch, displays charts. give little , feel, there's interaction graphs. , sometime, need more data backend (e.g. different chart types) using ajax request. since backend saved self signed certificate, doesn't work webview, know.

so, try accieve ajax request our js-app monotouch-app code, mono-app gets data webview , passes javascript function, updates charts new data.

but of right now, we're not able work, because call location.href = "app://get/chartdata" we're logging "about:blank" request, right before "app://get/chartdata" request, - of course - blanks webview , current chart gone. using simple ajax request doesn't work reason. meaning, ajax request doesn't call shouldloadstart callback. maybe, knows why?

here's our monotouch code far. testing general workflow!! ;-)

nsurl fileurl = nsurl.fromfilename("index.html");  nsurlrequest req = new nsurlrequest(fileurl); this.kpiwebview.loadrequest(req); this.kpiwebview.shouldstartload = myhandler;   this.kpiwebview.loadfinished += delegate {     indicator.stopanimating ();     this.kpiwebview.hidden = false; };   bool myhandler(uiwebview webview, nsurlrequest request, uiwebviewnavigationtype navtype) {     console.writeline(request.url.tostring());     if(request.url.tostring() == "about:blank")     {return false;} // doesn't avoid loading "about:blank"      if(request.url.tostring() == "ttl://data/salesgrowth/global")     {         string strdata = connection.login("http://[yourip/path]/salesgrowth/global");         return false;                         try{             this.kpiwebview.evaluatejavascript("util.loadstoredata("+strdata+")");                 return false;             }         catch(exception ex)             { console.writeline(ex.tostring()); }                        return true;     } } 

any comments, ideas , appreciated.

thanks!

edit: after more googleling found out, thing about:blank request known issue senach touch http://www.sencha.com/forum/showthread.php?123284-what-s-up-with-the-about-blank-page. finally, able getting run using our own url schema:

location.href = "app://action?jscallback=monocallback&jserrorcallback=errorcallback&paramname1=name1&paramval1=value1&..." 
in webview.shouldstartload callback, we're using system.uri namespace check app protocol , parameters , javascript callback function names. can our request within mono-app. after action, can call jscallback function
webview.evaluatejavascript(jscallback+"("+strvalues+")");
so, works fine now, asynchronous!

hope of you, struggeling same workflow issue self signed certificate within webview, find description helpful. if have more questions our "workaround" feel free contact me.

thanks!


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -