Hello, I need a way to send some script in a div or a form field to the server, have the server read it, then return the updated script to the div or form field. I can do the div and form field and such, I just need someone to explain to me how to do this. Can this be done? Thank you very much. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
1、send some script: var scriptString = "some script....."; var ajaxOptions = { method: "post", asynchronous: true, contentType: "application/x-www-form-urlencoded", encoding: "utf-8", parameters : "scriptString = " + scriptString, onSuccess : this.ajaxUpdate.bind(this), onFailure : this.handleError.bind(this) }; 2、execute the updated script: ajaxUpdate: function(request) { var updatedScriptString = request.responseText; updatedScriptString.evalScripts(); }, On 4月20日, 上午9时21分, Mike <mechanicc...-YDxpq3io04c@public.gmane.org> wrote:> Hello, I need a way to send some script in a div or a form field to > the server, > have the server read it, then return the updated script to the div or > form field. > > I can do the div and form field and such, I just need someone to > explain to me how to do this. Can this be done? Thank you very much.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I sure hope your onto something, I''ve been looking for ideas for this for months. I''ll try it and thanks! --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
If you can help me get this going I''ll send you something. I tried this: <script type="text/javascript" src="http://www.website.com/prototype/ prototype.js"> </head> <body> <div> <script type="text/javascript"> var scriptString = "<?php echo ''test'';?>"; var ajaxOptions = { method: "post", asynchronous: true, contentType: "application/x-www-form-urlencoded", encoding: "utf-8", parameters : "scriptString = " + scriptString, onSuccess : this.ajaxUpdate.bind(this), onFailure : this.handleError.bind(this) }; ajaxUpdate: function(request) { var updatedScriptString = request.responseText; updatedScriptString.evalScripts(); }, </script> </div> </body> </html> Just putting a basic echo first in the script area. Nothing happening yet. I figured the code should be in the head section but didn''t know how to add a div or form id to it. Please get back to me, thanks. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Mike, So you''ve got data in a variable named, say, script. OK. To send this to the server, you need to use an Ajax.Request to the server (this has to be the same server, and the same port, that you got your current web page from, btw). You''ll need to bind the onComplete (or onSuccess, depending on how picky you want to be) callback to a method of yours, in order to lookup the returned text. If I got you correctly, you''re not interested in evaluating the updated script, but in putting it back into its original place (form or field or whatever). So here''s an example: # HTML <form id="scripty" action="/your/updater/action"> <p><textarea id="script" name="script">some script</textarea></p> <p><input type="submit" value="Send it!"/></p> </form> #JS function bindFormToAJAX() { Event.observe(''scripty'', ''submit'', function(e) { Event.stop(e); $(''scripty'').request({ onComplete: function(transport) { $(''script'').value = transport.responseText; } }); }); } Event.observe(window, ''load'', bindFormToAJAX); The ''request'' method added to <form>s by Prototype basically uses the form''s fields, method (defaults to ''post'') and action to setup the AJAX call. We just provide AJAX options, which here include our ''onComplete'' callback, to put the updated script back in the <textarea> once we get the whole response. For more details on Ajax tools, just look at the docs (including JS auto-eval, for instance): http://prototypejs.org/api/ajax ''HTH -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks a bunch, please don''t leave me yet, I''ll send something to who helps me get this set up. Strangest thing, using this code, no form field is appearing on the page. Any idea why? What do I put in the action area? I do need the server to update my code then to send it back. Then later on I can figure out how to send it back to the server again. Please get back to me, thank you very much. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
It looks like you want the action=" " to be where my code from the form is sent. What kind of page can I send it to, so that the server executes it? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Mike, Mike a écrit :> Strangest thing, using this code, no form field is appearing on the > page. Any idea why? What do I put in the action area?Er, the code I sent was tested here and worked. Can you put your test page online, with the proper scripts and all, so that we can investigate further? -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, Mike a écrit :> It looks like you want the action=" " to be where my code from the > form is sent. What kind of page can I send it to, so that the server > executes it?Well, action= needs to point to whatever URL your server side binds to the code that will update your script. You mentioned you wanted the server to tweak the script text, so it would be the URL for the PHP/ASP/JSP/page or servlet or whatever that does the tweaking and sends the updated script. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, I was just getting an event undefined from the last part that confused me. OK, I understand where your headed now, sounds like the concept I need. Trouble is I don''t know how to complete the events on this side of the send. I could get someone else to help me on how to set up the action page on the other side to execute the script being sent. But this side.... I have been reading up on prototype for weeks now and have tried many things but I don''t know what I''m doing. If you or someone who knows how to do this can help me get these completes, successes, or event observes on this side working, I can pay 20.00 plus a page full of good links that may help you with some things. On this side I would need the script in the form to send without a page refresh. Then for the prototype script on this side to call it back again after so much time. If prototype is unable to call the scripts back after so much time, please let me know. Can you help? Thank you very much. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Forgot to say, when the call back brings it back would prefer no page refresh then either. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Can anyone help me with this? Can''t a form or div send and be called back with prototype without a page refresh? Thanks. On Apr 20, 2:50?am, Mike <mechanicc...-YDxpq3io04c@public.gmane.org> wrote:> Forgot to say, when the call back brings it back would prefer no page > refresh then either. Thanks.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Whats in the form I mean. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256> Then for the prototype script on this side to call it > back again after so much time. If prototype is unable to call the > scripts back after so much time, please let me know. Can you help? > Thank you very much.If you want the script to contact the server on a regular, repeating interval, you should probably investigate the Ajax.PeriodicalUpdater in the API. It will contact the server every specified number of seconds and then the information that it gathers will be placed in a specified HTML element on screen. On the other hand, if you just want to wait a certain quanta of time and then contact the server once, you''re best bet would be to use setTimeout() to delay the execution of a normal Ajax.Updater object. Does that help? - Dash - Mike wrote:> Thanks, I was just getting an event undefined from the last part that > confused me. > > OK, I understand where your headed now, sounds like the concept I > need. Trouble is I don''t know how to complete the events on this side > of the send. I could get someone else to help me on how to set up the > action page on the other side to execute the script being sent. But > this side.... I have been reading up on prototype for weeks now and > have tried many things but I don''t know what I''m doing. If you or > someone who knows how to do this can help me get these completes, > successes, or event observes on this side working, I can pay 20.00 > plus a page full of good links that may help you with some things. > > On this side I would need the script in the form to send without a > page refresh. Then for the prototype script on this side to call it > back again after so much time. If prototype is unable to call the > scripts back after so much time, please let me know. Can you help? > Thank you very much. > > > > > >-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGKSjc6r+BYsa3/iMRCOngAKDB3iXl3t8UtuTr0w3QdJi8RZoKfwCfd96u Wn+kLlXtx0AkkiYBctiIohs=5uij -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you very much. If anyone one knows how to set it up for me I would pay as explained above. Otherwise I''ll start reading about your last suggestion, until I hear from someone. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I also have some good working php mysql server code I can give you as well. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---