javascript - jQuery cache XML -


I am trying to create a portfolio site where my pieces remain in the XML file I stored the XML DOM in the javascript variable So that I can access it every time a user clicks to load a new piece without having to call the server.

I have it now:

  $ (document) .ready (function () {xml = getXML ();}); Function getXML () {var data = $. Ajax ({url: '_lib / xml / portfolio.xml', datatype: 'xml', success: function (data) {return data;}}); Return data; }  

While using firebug, if "console.log (data)" in anonymous function after "success", then it logs "document". If I "console.log (xml)" .ready ... "in" $ (document), it logs an XMLHTTPRequest and I can not access the DOM of the XML document.

I have tried "data. ResponseXML" is returning but it does nothing, I have tried to do a non-anonymous work after "success" and here is the XML logging, and It still comes in the form of a "document" which is what I want

It seems that the problem occurs when I return XML - it changes from "document" to "XMLHTTPRequest"

Any help would be greatly appreciated thanks! Try it out:

  function getXML () {var XML =     

I do not know whether ' $ .jax ' returns, but I have tried like you and it never works. So the above code is the one I deal with.

Edit Just want to emphasize that you have to do in ' async: false ' Ajax request.

Hope it helps.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -