1

i am trying to read an XML from SD card in jQuery function .. the html file is loaded in webView of android device...here is what i am trying

<script type="text/javascript">
  $(document).ready(function(){
  $("#dvContent").append("<ul></ul>");
  $.ajax({
    type: "GET",
    url: "file:///mnt/sdcard/RegInfo/output/data.xml",
    dataType: "xml",
    success: function(xml){
    $(xml).find('Book').each(function(){
      var sName = $(this).find('Name').text();
      var sEmail = $(this).find('Email').text();
      $("<li></li>").html(sName + "-" + sEmail).appendTo("#list");
    });
  },
  error: function() {
    alert("An error occurred while processing XML file.");
  }
  });
});
</script>

there is something wrong with the file url but i am not being able to figure out the problem... The code is working fine with desktop browser . . . and i am not using PhoneGAp.js or Cordova.js

AddyProg
  • 2,960
  • 13
  • 59
  • 110
  • what am i doing!!! need my eyes examined. :) sorry WEBVIEW. ill have a look at my notes, and get back if i spot anything – Tasos Mar 24 '14 at 12:20
  • According to this http://stackoverflow.com/questions/19379392/jquery-mobile-not-working-in-webview-when-loading-from-local-assets --- check your build version, it may be the same issue, it was solved by adding --- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ s.setAllowUniversalAccessFromFileURLs(true); s.setAllowFileAccessFromFileURLs(true); } ---- not sure were he added that code though. – Tasos Mar 24 '14 at 12:28
  • yeah i did looked at this but in my case its android 2.2 – AddyProg Mar 24 '14 at 12:30
  • Using the simulator did you get any errors from the console? – Tasos Mar 24 '14 at 12:41
  • no errors.. i can even access this file via mobile browser with this link file:///mnt/sdcard/RegInfo/output/data.xml – AddyProg Mar 25 '14 at 04:07

0 Answers0