Ajax not working in webview android -


i trying call ajax android webview , it's not working. getting error in console window

08-29 12:28:16.411: e/content(14146): [object object] @ 1: http://loconav.com/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js 08-29 12:28:16.536: e/content(14146): uncaught typeerror: undefined not function @ 1: http://loconav.com/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js 08-29 12:28:16.683: e/content(14146): uncaught typeerror: undefined not function @ 1: http://loconav.com/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js 08-29 12:28:16.883: e/content(14146): uncaught typeerror: undefined not function @ 1: http://loconav.com/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js 08-29 12:28:17.202: e/content(14146): uncaught typeerror: undefined not function @ 1: http://loconav.com/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js 

i using android code

webview = (webview) findviewbyid(r.id.webview);         webview.setwebviewclient(new webviewclient(){              @override             public boolean shouldoverrideurlloading(webview view, string url)             {                 return super.shouldoverrideurlloading(view, url);             }              public void onpagestarted(webview view, string url, bitmap favicon) {                 dialog.show();             }              @override             public void onpagefinished(webview view, string url) {                 if(url.equals("http://xyz")){                     editor.putstring("login", "true");                     editor.commit();                     trytologin = false;                 }else if(url.equals("http://xyz")){                     editor.clear();                     editor.commit();                     intent intent = new intent(webactivity.this,mainactivity.class);                     if(trytologin == true){                         intent.putextra("login", "failed");                     }                     startactivity(intent);                     finish();                 }                 if(!isnetworkavailable()){                     alertdialog();                     linearlayout.setvisibility(view.visible);                     webview.setvisibility(view.gone);                 }else{                     webview.setvisibility(view.visible);                     imageview.setvisibility(view.visible);                 }                 dialog.dismiss();                 //pd.dismiss();                 //toast.maketext(webactivity.this, url, toast.length_long).show();             }         });         webview.setwebchromeclient(new webchromeclient(){              @override                 public boolean onconsolemessage(consolemessage cm)                 {                     log.e("content", string.format("%s @ %d: %s",                                  cm.message(), cm.linenumber(), cm.sourceid()));                     return true;                 }         });         webview.getsettings().setjavascriptenabled(true);         webview.getsettings().setappcacheenabled(true);         webview.getsettings().setdatabaseenabled(true);         webview.getsettings().setdomstorageenabled(true);         webview.getsettings().setrenderpriority(websettings.renderpriority.high);         webview.getsettings().setsupportzoom(true);         webview.getsettings().setjavascriptcanopenwindowsautomatically(true);         webview.getsettings().setallowfileaccessfromfileurls(true);         webview.getsettings().setallowuniversalaccessfromfileurls(true);         webview.getsettings().setloadsimagesautomatically(true);         webview.getsettings().setjavascriptcanopenwindowsautomatically(true);         webview.getsettings().setloadwithoverviewmode(true);         webview.getsettings().setallowcontentaccess(true);         webview.getsettings().setusewideviewport(true); 

i trying call ajax file

function googlefetchandfillhistorylocation(t,e,n,o){$.ajax({url:"http://maps.googleapis.com/maps/api/geocode/json?latlng="+t+","+e,success:function(t){var e=[],c="",r="";t.results[0].address_components.foreach(function(t,n,o){"unnamed road"!=t.long_name&&e.push(t.long_name),t.types.includes("sublocality")&&(c=t.long_name),t.types.includes("locality")&&(r=t.long_name)}),console.log(t.results[0].formatted_address);var i=e.join(", "),a=c+", "+r;o.html(i),n.html(a)},error:function(t){o.html("some error occurred while fetching address")}})}function historyselector(t){this.$selector=t}!function(t){"use strict";var e=function(t,n){var o=/[^\w\-\.:]/.test(t)?new function(e.arg+",tmpl","var _e=tmpl.encode"+e.helper+",_s='"+t.replace(e.regexp,e.func)+"';return _s;"):e.cache[t]=e.cache[t]||e(e.load(t));return n?o(n,e):function(t){return o(t,e)}};e.cache={},e.load=function(t){return document.getelementbyid(t).innerhtml},e.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\s]+?)%\})|(\{%)|(%\})/g,e.func=function(t,e,n,o,c,r){return e?{"\n":"\\n","\r":"\\r","    ":"\\t"," ":" "}[e]||"\\"+e:n?"="===n?"'+_e("+o+")+'":"'+("+o+"==null?'':"+o+")+'":c?"';":r?"_s+='":void 0},e.encreg=/[<>&"'\x00]/g,e.encmap={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#39;"},e.encode=function(t){return(null==t?"":""+t).replace(e.encreg,function(t){return e.encmap[t]||""})},e.arg="o",e.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return e}):t.tmpl=e}(this),historyselector.prototype.bindevents=function(){var t=this;this.$selector.on("change",function(){t.fetchdata()})},historyselector.prototype.fetchdata=function(){$.ajax({context:this,url:this.$selector.data("url"),data:{profiles:{interval:this.$selector.val()}},headers:{"x-auth-token":$("#auth-token").data("token")},success:function(t){console.log(t),this.populatedata(t),$(".location-panel").each(function(t,e){var n=$(e);settimeout(function(){googlefetchandfillhistorylocation(n.data("lat"),n.data("long"),n.find(".short-location"),n.find(".formatted-address"))},200*t)})},error:function(t){console.log(t)}})},historyselector.prototype.populatedata=function(t){var e=$(tmpl("history-locations",t).trim());$(".history-locations").empty().append(e),$("body").scrolltop()<180&&$("html, body").animate({scrolltop:"180vh"},"slow")},historyselector.prototype.init=function(){},$(function(){$(".selectors input").each(function(){var t=new historyselector($(this));t.init(),t.bindevents()})}); 

you can see ajax file on link - http://www.loconav.com/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js

i using html code

    <!doctype html> <html lang="en">   <head>     <meta charset="utf-8">     <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>babatrucks</title>     <meta content="authenticity_token" name="csrf-param" /> <meta content="lnjn5/glbns0cguyjalfut+usgccdckhwhcqi32oej0=" name="csrf-token" />      <link href="/assets/application-33b3164661d3b2d630f9cbc88419feb4.css" media="all" rel="stylesheet" />     <link href="/assets/m_application-9613cb73f45d486ef514a74fa1964a46.css" media="all" rel="stylesheet" />      <script src="/assets/application-95d8b0297f927b393dd0e1aaf163bc4d.js"></script>   </head>   <body>      <div class="container">       <div class="row">         <div class="col-xs-12">           <link href="/assets/m/trucks/show-bcd1a590d01e03df2a78b4c5dbd1a975.css" media="screen" rel="stylesheet" /> <script src="/assets/m/history_selector-1b620f001e31e9dfeff6981b3ee9b290.js"></script> <div class="row top-bar">   <div class="col-xs-2 text-center">     <a class="back-arrow" href="/m/trucks">       <i class="fa fa-chevron-left" aria-hidden="true"></i> </a>  </div>   <div class="col-xs-8 text-center title">     nl 01l 2273   </div>   <div class="col-xs-2 text-right">   </div> </div> <div class="row">   <iframe class='locate-map' src="/m/trucks/296/locate"></iframe>   <div class="col-xs-12">     <div class="row">       <div class="selectors rohan-container">         <ul class="backline">           <hr class="rohan-hr">           <li>             <label for="profiles_interval_1">1 hours</label>             <!-- <input type="radio" id="f-option" name="selector"> -->             <input data-url="http://www.example.com/" id="profiles_interval_1" name="profiles[interval]" type="radio" value="1" />             <div class="check"></div>           </li>            <li>             <label for="profiles_interval_6">6 hours</label>             <!-- <input type="radio" id="s-option" name="selector"> -->             <input data-url="http://www.example.com/" id="profiles_interval_6" name="profiles[interval]" type="radio" value="6" />             <div class="check">               <div class="inside"></div>             </div>           </li>            <li>             <label for="profiles_interval_24">24 hours</label>             <!-- <input type="radio" id="t-option" name="selector"> -->             <input data-url="http://www.example.com/" id="profiles_interval_24" name="profiles[interval]" type="radio" value="24" />             <div class="check">               <div class="inside"></div>             </div>           </li>         </ul>       </div>       <!-- rohan ends -->     </div>     <div class="row history">       <div class="col-xs-12">         <div class="row">           <div class="history-locations col-xs-12"></div>         </div>       </div>     </div>   </div> </div> <div class="hidden" id="auth-token" data-token=""></div> <script src="/assets/timeline/modernizr-04ac4151e53119ba85cdc7679379cd0d.js"></script> <script type="text/x-tmpl" id="history-locations">   <section id="cd-timeline" class="cd-container">     {% (var = 0; < o['profiles'].length; i++) { %}       <div class="cd-timeline-block location-panel" data-lat="{%= o['profiles'][i]['lat'] %}" data-long="{%= o['profiles'][i]['long'] %}">         <div class="cd-timeline-img cd-picture">           <img alt="picture" src="/assets/timeline/cd-icon-location-20955b176b47169a313e3c8c11803cc1.svg" />         </div> <!-- cd-timeline-img -->          <div class="cd-timeline-content">           <h2 class="">{%= o['profiles'][i]['actual_received_at'] %}</h2>           <p class="formatted-address"></p>         </div> <!-- cd-timeline-content -->       </div> <!-- cd-timeline-block -->     {% } %}   </section> </script> <script src="/assets/timeline/main-f1dcfd5d7be80e6258f34c7dded2ee86.js"></script>   <script type="text/javascript">   function fetchandfilllocation(lat, long, infodiv, trucknumber, speed) {     var request = new xmlhttprequest();     var method = 'get';     var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='               + lat               + ','               + long               + '&sensor=true';     var async = true;     request.open(method, url, async);     request.onreadystatechange = function(){       if(request.readystate == 4 && request.status == 200){         var data = json.parse(request.responsetext);         var address = data.results[0];         infodiv.empty();         infodiv.append('<div class="info-box-title"><span class="left-align-number"><i class="fa fa-truck"></i> '+ trucknumber +'</span><span class="right-align-speed"><i class="fa fa-tachometer"></i> ' + speed + ' km/h</span></div><div class="info-box-text">' + address.formatted_address + '</div>');       }     };     request.send();   }    function updatemarkerposition(current_location_div) {     var request = new xmlhttprequest();     var method = 'get';     var url = '/api/v1/trucks/location?truck[slug]=abc';     var async = true;     request.open(method, url, async);     request.setrequestheader('x-auth-token', 'abc');     request.onreadystatechange = function(){       if(request.readystate == 4){         if(request.status == 200) {           var data = json.parse(request.responsetext).current_cordinate;           var truckcords = { lat: data.lat, lng: data.long }           fetchandfilllocation(truckcords.lat, truckcords.lng, current_location_div, data.key, data.speed);         }         settimeout(function() {           updatemarkerposition(current_location_div)         }, 10000);       }     };     request.send();   }   $(function() {     updatemarkerposition($('.current-location'));   }) </script>         </div>       </div><!--/row-->        <footer>       </footer>      </div> <!-- /container -->      <script>   (function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new date();a=s.createelement(o),   m=s.getelementsbytagname(o)[0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m)   })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');    ga('create', 'ua-81486803-1', 'auto');   ga('send', 'pageview'); </script>   </body> </html> 

how can solve error advance

i assume, lot of individual files don't end code semicolon. jquery scripts end (jquery) , need have (jquery);.
consider adding jquery locally or via cdn.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -