Thanks for your answer > dynamically creating a <script> tag and inserting > it into the dom to create functionality once the page has been loaded on > the client system?
Yes exactly, I'm try to include the script of MyBlogLog that should be: <script src="http://pub.mybloglog.com/comm2.php?mblID=2006121510341039" type="text/javascript"></script> The url is longer normally and it works. When requesting from browser: http://pub.mybloglog.com/comm2.php?mblID=2006121510341039 This will return a script that generate <table> So I try: Event.observe(window, 'load', function() { // Using 'static' object JCMS.plugin.mybloglog.MyBlogLog.insertScript(); }); Then I'm using a <a href="mybloglog url"></a> to retrieve the location and url to call JCMS.plugin.mybloglog.MyBlogLog = { insertScript : function () { var elm = $('MyBlogLog'); var url = elm.href; var address = url.substring(0,url.indexOf('?')); var params = $H(url.toQueryParams()); /* Option 1 var script = document.createElement('SCRIPT'); script.type='text/javascript'; script.src = address+"?"+params.toQueryString(); elm.parentNode.appendChild(script); */ /* Option 2 // elm.parentNode.innerHTML = "<script type='text/javascript' src='"+address+"?"+params.toQueryString()+"'></script>" */ /* Option 3 new Ajax.Updater(elm.parentNode, address, { parameters: { mblID: '2006121510341039', } */ }); } }; - I don't know what is the best way to do it ? - I do not want to directly write the <script> tag in the page because it may slow down the page loading. - How can I have the response code from the Ajax request ? - Should I set a userAgent ? Thanks On Jan 27, 2008 9:20 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > On Jan 27, 2008 3:02 PM, Jean-Philippe Encausse <[EMAIL PROTECTED]> wrote: > > > 1. I call a script Event.observe(window, 'load', ... > > 2.1 I generate <script></script> under a given Id > im not entirely sure what you mean here, can you be more specific? > for example, are you dynamically creating a <script> tag and inserting > it into the dom to create functionality once the page has been loaded on > the client system? > > > > 2.1.1 with InnerHTML it do not work > try Element.insert(); > http://www.prototypejs.org/api/element/insert > > > > 2.1.2 with dom elments it works but override the full page > hmm; is the container element properly closed in the dom? > > > > 2.2 Using Ajax.Updater it seems connection fails > verify the url is valid. > check the response code from the server. > look into firebug. > > > > - What is the best practice tounderstand why the connection is refused ? > you need to verify the url you are requesting is legitimate. > you can paste the url in the browser and see if you get a response. > you may not even be contacting the webserver, depending on the url. > if you are contacting the webserver, you should look at the response code. > this will give you insight as to why the server could not respond w/ a valid > resource. > have you worked with firebug for firefox, it allows you to monitor ajax > calls. > > > - What is the best pratice to include a <script> tag in a given place > > of the DOM ? > If you mean dynamically, during an Ajax request, then Ajax.Updater will run > anything > enclosed in <script> tags (in the response) through a call to eval(), > provided > you set the Ajax option, evalScripts to true when you instantiate > Ajax.Updater. > > -nathan > > > > -- Jean-Philippe Encausse - Veille / R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
