Hi, a Javascript in one of my Rails templates needs to load a static XML file. I tried several places to put the actual XML file, and I also tried to make the file a rails template (tried both .rhtml and .rxml) and access it via a controller action. None of these ways worked. Does the lighttpd server know how to serve XML files, or do I need to configure it first? Or, is there a good workaround? Ingo Weiss
Hi, a Javascript in one of my Rails templates needs to load a static XML file. I tried several places to put the actual XML file, and I also tried to make the file a rails template (tried both .rhtml and .rxml) and access it via a controller action. None of these ways worked. Does the lighttpd server know how to serve XML files, or do I need to configure it first? Or, is there a good workaround? Ingo Weiss
Did you try putting it in your public folder? On 4/17/06, Ingo Weiss <ingo@ingoweiss.com> wrote:> Hi, > > a Javascript in one of my Rails templates needs to load a static XML > file. I tried several places to put the actual XML file, and I also > tried to make the file a rails template (tried both .rhtml and .rxml) > and access it via a controller action. None of these ways worked. Does > the lighttpd server know how to serve XML files, or do I need to > configure it first? Or, is there a good workaround? > > Ingo Weiss > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com
Ingo Weiss wrote:> Hi, > > a Javascript in one of my Rails templates needs to load a static XML > file. I tried several places to put the actual XML file, and I also > tried to make the file a rails template (tried both .rhtml and .rxml) > and access it via a controller action. None of these ways worked. Does > the lighttpd server know how to serve XML files, or do I need to > configure it first? Or, is there a good workaround? > > Ingo WeissWhy can''t you just put it in public/ under ''whatever.xml''? Content under public gets served static. If for some reason the file is inaccessible, it may have something to do with Lighty not serving .xml files under the right MIME type. -- Posted via http://www.ruby-forum.com/.
> Did you try putting it in your public folder?Yes that was the first thing I tried. Here is my Javascript code: function loadXML() { var request = GXmlHttp.create(); request.open("GET", "myfile.xml", true); # or "/myfile.xml" request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; .... } } } request.send(null); } The exact same code worked just fine before with a dynamix .rxml file, but not it generates the following error: "xmlDoc has no properties" Ingo
Ingo Weiss wrote:>> Did you try putting it in your public folder? > > > Yes that was the first thing I tried. Here is my Javascript code: > > > function loadXML() { > var request = GXmlHttp.create(); > request.open("GET", "myfile.xml", true); # or "/myfile.xml" > request.onreadystatechange = function() { > if (request.readyState == 4) { > var xmlDoc = request.responseXML; > > .... > > } > } > } > request.send(null); > } > > > The exact same code worked just fine before with a dynamix .rxml file, > but not it generates the following error: > > "xmlDoc has no properties"Did you configure a mime type for .xml in you lighttpd.conf? -- Ray
> Did you configure a mime type for .xml in you lighttpd.conf?Good point! I did not. What is the right type for xml files? I tried "text/xml" and "application/xml", restarted the server, but now the file is served as a binary and a download window pops up. Thanks! Ingo Weiss> Ingo Weiss wrote: > >> Did you try putting it in your public folder? > > > > > > Yes that was the first thing I tried. Here is my Javascript code: > > > > > > function loadXML() { > > var request = GXmlHttp.create(); > > request.open("GET", "myfile.xml", true); # or "/myfile.xml" > > request.onreadystatechange = function() { > > if (request.readyState == 4) { > > var xmlDoc = request.responseXML; > > > > .... > > > > } > > } > > } > > request.send(null); > > } > > > > > > The exact same code worked just fine before with a dynamix .rxmlfile,> > but not it generates the following error: > > > > "xmlDoc has no properties" > > Did you configure a mime type for .xml in you lighttpd.conf? >
I beleive it is application/xml On 4/18/06, Ingo Weiss <ingo01@ingoweiss.com> wrote:> > Did you configure a mime type for .xml in you lighttpd.conf? > > > Good point! I did not. What is the right type for xml files? I tried > "text/xml" and "application/xml", restarted the server, but now the file > is served as a binary and a download window pops up. > > Thanks! > Ingo Weiss > > > > > Ingo Weiss wrote: > > >> Did you try putting it in your public folder? > > > > > > > > > Yes that was the first thing I tried. Here is my Javascript code: > > > > > > > > > function loadXML() { > > > var request = GXmlHttp.create(); > > > request.open("GET", "myfile.xml", true); # or "/myfile.xml" > > > request.onreadystatechange = function() { > > > if (request.readyState == 4) { > > > var xmlDoc = request.responseXML; > > > > > > .... > > > > > > } > > > } > > > } > > > request.send(null); > > > } > > > > > > > > > The exact same code worked just fine before with a dynamix .rxml > file, > > > but not it generates the following error: > > > > > > "xmlDoc has no properties" > > > > Did you configure a mime type for .xml in you lighttpd.conf? > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -------------- Jon Gretar Borgthorsson http://www.jongretar.net/