I made a script to get the results of a XML file: // to encode the url function URLencode(sStr) { return escape(sStr). replace(/\+/g, '%2B'). replace(/\"/g,'%22'). replace(/\'/g, '%27'). replace(/\//g,'%2F'); } function requestUrl() { // get the string of a input text var linkinput = $F('linkinput') // encode the input text var linkencod = URLencode($F('linkinput')) // div of the result var resultinput = $('resultinput') var twittar = $('twittar') var conta = $('conta')
// send the URL encoded to the xml new Ajax.Request('http://migre.me/api.xml?url=' + URLencode($F ('linkinput')), { method: 'get', // on create, execute the effects (scriptaculous) onCreate: function() { Effect.DropOut('link'); Effect.Appear('result'); }, // on success, update some strings with the response onSuccess: function(transport) { if (transport.responseXML.getElementsByTagName( 'error' ) == '0') { var migre = transport.responseXML.getElementsByTagName( 'migre' ); conta.update('-' + linkinput-migre + '!') resultinput.update('O link curto é <a href="' + migre + '">' + migre + '</a>'); twittar.update('<a href="http://twitter.com/home?status=' + migre + '>twittar agora este link</a>');} // if the <error> tag is not 0 else var erro = transport.responseXML.getElementsByTagName( 'error' ); resultinput.update('Houve um erro ao encurtar seu link.<br /> O servidor respondeu com o erro' + erro); }, }); } Problem: does not work just work the onCreate, but don't work the onSuccess. Help please? ADDITIONAL: HTML FILE: <html> <head> <meta content="text/html;charset=UTF-8" http-equiv="content-type"/> <title>Teste frameworks</title> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <link media="all" type="text/css" href="estilo.css" rel="stylesheet"> </head> <body> <div id="desc1">encurta</div> <div id="desc2">e registra</div> <div id="title"><a href="#" onclick="alert('OK funfa em')">migre.me</ a></div> <div id="result" style="display: none;"> <span id="resultinput">Encurtando…</span> <br /> <span id="conta" class="conta"></span><br /> <span id="twittar" class="twittar"></span> </div> <div id="link"> Encurtar o link:<br /> <input type="text" name="linkinput" id="linkinput" size="45" onkeypress="if(event.keyCode==13){ requestUrl(); }"> <input type="button" name="OK" value="OK" onclick="requestUrl();" /> </div> <script type="text/javascript"> function URLencode(sStr) { return escape(sStr). replace(/\+/g, '%2B'). replace(/\"/g,'%22'). replace(/\'/g, '%27'). replace(/\//g,'%2F'); } function requestUrl() { var linkinput = $F('linkinput') var linkencod = URLencode($F('linkinput')) var resultinput = $('resultinput') var twittar = $('twittar') var conta = $('conta') new Ajax.Request('http://migre.me/api.xml?url=' + URLencode($F ('linkinput')), { method: 'get', onCreate: function() { Effect.DropOut('link'); Effect.Appear('result'); }, onSuccess: function(transport) { if (transport.responseXML.getElementsByTagName( 'error' ) == '0') { var migre = transport.responseXML.getElementsByTagName( 'migre' ); conta.update('-' + linkinput-migre + '!') resultinput.update('O link curto é <a href="' + migre + '">' + migre + '</a>'); twittar.update('<a href="http://twitter.com/home?status=' + migre + '>twittar agora este link</a>');} else var erro = transport.responseXML.getElementsByTagName( 'error' ); resultinput.update('Houve um erro ao encurtar seu link.<br /> O servidor respondeu com o erro' + erro); }, }); } </script> </body> </html> XML ESTRUCTURE: <item> <title>XML Migre.me</title> <error>0</error> // date <created_at>Sun, 15 Feb 2009 19:11:55 -0300</created_at> <source>api</source> <date>2009-02-15 19:11:55</date> <id>19E</id> <url>http://www.youtube.com/watch?v=btAaUZIhV6c</url> // the url shortened <migre>http://migre.me/19E</migre> <category>free</category> </item> Thanks, Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---