html - Allow access to a locally stored XML from Internet Explorer9 -
i'm developing webapp in html5 must work locally.
is app design datamodel, , should parse tables informations xml well-formed file , render them in html. want create custom views, telling script wich tables parse xml passing names via parameters in th url.
to this, i'm using jquery's $.ajax method, developed in firefox , goes well. need working on ie9, , using both $.ajax , xmlhttprequest receive "access denied" error.
here script working on firefox:
$(document).ready(function () { // // rilevo la stringa dell'url che contiene nomi delle tabelle da visualizzare var query = window.location.search.substring(1); // se c'è if (query){ // alert('query= '+query); var tabelle = query.split('&'); // alert('lunghezza array tabelle= '+tabelle.length); $.ajax({ type: "get", url: "tables.xml", datatype: "xml", async: false, success: function(xml) { alert('start loading tables'); // var i_success = 0; for(var i_success=0; i_success<tabelle.length; i_success++){ $(xml).find('tabella').each(function(){ // alert('pars+write tabella '+i_success+': id= '+tabelle[i_success]); if ($(this).find('id').text() == tabelle[i_success]) { var id = $(this).find('id').text(); // //verifico che la tabella sia tra quelle passatemi nell'url // var found = $.inarray(id, tabelle) > -1; var classe = $(this).attr('classe'); var title = $(this).find('title').text(); $('<div class="drag tab" id="'+id+'"></div>').html('<h2 class="th">'+title+'</h2>').appendto('#content'); var i_celle = 0; $(this).find('cella').each(function() { var id_cella = $(this).find('id_cella').text(); var content = $(this).find('content').text(); $('<div class="td '+id_cella+'">'+content+'</div>').appendto('#'+id); i_celle++; }); // continue; } else { return; } });// end find each } //end },//end success complete: function(){ togglefields(); connections(); togglebg(); alert('complete'); },//end complete error: function(richiesta,stato,errori){ $("#content").html("<strong>caricamento delle tabelle fallito:</strong><br/>"+stato+" "+errori); }//end error }); //end ajax } else { alert('non sono state fornite tabelle da visualizzare...'); } });` here code i'm trying implement ie:
$(document).ready(function () { // // rilevo la stringa dell'url che contiene nomi delle tabelle da visualizzare var query = window.location.search.substring(1); // se c'è if (query){ alert('query= '+query); var tabelle = query.split('&'); alert('lunghezza array tabelle= '+tabelle.length); var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari alert('questo browser supporta xmlhttprequest! :)'); xmlhttp=new xmlhttprequest(); alert('xmlhttprequest creata con successo'); xmlhttp.open("get","tables.xml",true); alert('richiesta aperta'); xmlhttp.send(); alert('request inviata con successo'); } else {// code ie6, ie5 alert('xmlhttprequest non supportata da questo browser'); xmlhttp=new activexobject("microsoft.xmlhttp"); } } else { alert('non sono state fornite tabelle da visualizzare...'); }// end if query }); // end document.ready can me please? i'm getting crazy..
i managed fix.
i decided pass data in json object inline.
you can in html dom, using
<script type="application/json" id="stuff> json code here </script> and call in js using var myvar=json.parse(document.getelementbyid('stuff').innerhtml); html% valid: http://dev.w3.org/html5/spec/overview.html#the-script-element .
i decided write directly in js, , call var. var tabobj = {"tabelle": json code }; have understand yet if have parse or if not mandatory.
that's folks. help, know strange question.
Comments
Post a Comment