jquery - XMLHttpRequest file load error. What should the file format contain? -


i have taken basic xml retrieval net, cannot reproduce on network drive. want test out , make sure can reproduce before starting small project. issue on line 55 (xmlhttp.send();). these errors.

xmlhttprequest cannot load file:///y:/bwi/cd_catalog.xml. cross origin requests supported protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. uncaught networkerror: failed execute 'send' on 'xmlhttprequest': failed load 'file:///y:/bwi/cd_catalog.xml'.

i figured has formatting of file load (file:///y:/bwi/cd_catalog.xml). should proper format in order simple html page read file?

<!doctype html> <html> <head> <script> function loadxmldoc(url) { var xmlhttp; var txt,x,xx,i; if (window.xmlhttprequest)   {// code ie7+, firefox, chrome, opera, safari   xmlhttp=new xmlhttprequest();   } else   {// code ie6, ie5   xmlhttp=new activexobject("microsoft.xmlhttp");   } xmlhttp.onreadystatechange=function()   {   if (xmlhttp.readystate==4 && xmlhttp.status==200)     {     txt="<table border='1'><tr><th>title</th><th>artist</th></tr>";     x=xmlhttp.responsexml.documentelement.getelementsbytagname("cd");     (i=0;i<x.length;i++)       {       txt=txt + "<tr>";       xx=x[i].getelementsbytagname("title");         {         try           {           txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>";           }         catch (er)           {           txt=txt + "<td> </td>";           }         }       xx=x[i].getelementsbytagname("artist");         {         try           {           txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>";           }         catch (er)           {           txt=txt + "<td> </td>";           }         }       txt=txt + "</tr>";       }     txt=txt + "</table>";     document.getelementbyid('txtcdinfo').innerhtml=txt;     }   } xmlhttp.open("get",url,true); xmlhttp.send(); } </script> </head> <body>  <div id="txtcdinfo"> <button onclick="loadxmldoc('cd_catalog.xml')">get cd info</button> </div>  </body> </html> 

what should proper format in order simple html page read file?

it should http:// something. need run webserver. can't access file systems directly.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -