geek Posted May 7, 2012 at 03:34 PM Report #453578 Posted May 7, 2012 at 03:34 PM Boas Pessoal, Estou a dar as primeiras pisadas no javascript, e gostava que alguém me ajudasse. Gostaria de saber como posso fazer download de um ficheiro, neste caso um ficheiro xml (http://www.uniprot.org/uniprot/?query=QDC&format=xml) para um ficheiro e para uma string. já dei umas pesquisas na net mas não encontrei nada que funcionasse! Aguardo uma ajudinha. Obrigado 😄
KTachyon Posted May 7, 2012 at 05:36 PM Report #453610 Posted May 7, 2012 at 05:36 PM Con JQuery podes utilizar o método ajax() para fazeres o pedido pelo XML. Quanto a salvar em ficheiro, não estou a ver a utilidade da coisa, mas penso que já me passou por aqui alguma coisa sobre isso. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
geek Posted May 8, 2012 at 10:32 AM Author Report #453727 Posted May 8, 2012 at 10:32 AM não há outra forma?
brunoais Posted May 8, 2012 at 10:48 AM Report #453733 Posted May 8, 2012 at 10:48 AM não há outra forma? Usar o que o browser tem nativamente. XMLHttpRequest() "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
geek Posted May 8, 2012 at 11:07 AM Author Report #453746 Posted May 8, 2012 at 11:07 AM podes dar-me um exemplo mesmo em codigo? sou um bocado leigo nisto :X Se poderes agradecia.. nem que seja um exmplo basico que retirar o texto de uma pagina html para um string..
brunoais Posted May 8, 2012 at 02:11 PM Report #453821 Posted May 8, 2012 at 02:11 PM Tens um exemplo manhoso aqui: http://www.w3.org/TR/XMLHttpRequest/#introduction "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
geek Posted May 9, 2012 at 05:28 PM Author Report #454133 Posted May 9, 2012 at 05:28 PM é mesmo manhoso e não percebi. Ninguém me arranja um exmplo? :down:
brunoais Posted May 9, 2012 at 05:45 PM Report #454135 Posted May 9, 2012 at 05:45 PM Vamos ver se percebi... Tu queres fazer download do ficheiro para usar na página? Tu queres fazer download do ficheiro para gravar no disco? "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
geek Posted May 15, 2012 at 09:27 PM Author Report #455913 Posted May 15, 2012 at 09:27 PM Vamos ver se percebi... Tu queres fazer download do ficheiro para usar na página? Tu queres fazer download do ficheiro para gravar no disco? eu quero fazer o download para uma string, para depois usar na página 🙂
brunoais Posted May 16, 2012 at 06:02 AM Report #455953 Posted May 16, 2012 at 06:02 AM function someName (callback){ xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","page.xml",true); xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ callback(xmlhttp.responseXML); } } xmlhttp.send(); } Depois usas o parser interno do browser para navegar no documento XML. "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now