Hi. I am very, very new to this. I have a form that I''m trying to transfer into ajax. It worked just fine the old fashion way, but now that I''m using prototype.js, none of the data is going through.The email is being sent, but there is nothing in the email. The information went through perfectly before. That''s the first problem. Secondly, I''m trying to update an element on the onSuccess. I realize I should be using the ajax.updater, but can''t quite figure out the API for it. Any help would be appreciated. Here is the .js file named ajax.js function doSubmit() { var url = ''http://www.xxxxxxxxxxxx.com/contact/sendmail.php''; new Ajax.Request( url, { method: ''Post'', onSuccess: showResponse }); } function showResponse() { var inputName = $F(''firstname''); var results = $(''contactformholder''); results.innerHTML = ''<p><br>Thank you <br>'' + inputName + ''</p>'' } And the simplified HTML. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script src="prototype.js" type="text/javascript"></script> <script src="ajax.js" type="text/javascript"></script> </head> <table> <tr><td id="contactformholder"> <form name="contact"> <table> <tr> <td >First Name</td> <td><input type="text" name="firstname"></td> </tr> <tr> <td>Last Name </td> <td><input type="text" name="lastname"></td> </tr> <tr> <td></td> <td><input align="right" type="button" value="send" onClick="doSubmit()"></td> </tr> </table> </form> </td></tr></table> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, Looks like you''re doing an Ajax request to another domain, which is a violation of the SOP (http://en.wikipedia.org/wiki/ Same_origin_policy). And probably explains why you are having issues. You can find more documentation on Ajax on the Prototype website: http://prototypejs.org/api/ajax/ and http://prototypejs.org/learn/introduction-to-ajax Regards, Tobie --~--~---------~--~----~------------~-------~--~----~ 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 Catherine, Well, there are a lot of minor issues with your markup alone (accessibility, strictness, and the like), but few of these pertain to your current problem, so I''ll stay away from them.> function doSubmit() { > var url = ''http://www.xxxxxxxxxxxx.com/contact/sendmail.php''; > new Ajax.Request(url, { > method: ''Post'', > onSuccess: showResponse > }); > }OK, first, prefer lowercase ''post''. Same for ''get'' (otherwise you''ll end up defaulting to ''post'' with your original value in a hidden _method field, for Rails-related reasons). Second, ''post'' is actually the default: you can do away with it. Third, *where* are your parameters? I don''t see any data anywhere! You''re probably looking for an extra option that looks like this: postBody: Form.serialize(''contact'') Note that you will need to add an id="contact" to your <form>: the nameattribute has been deprecated on forms since HTML 4.01, 8 years ago. And Prototype only works with ID attributes when using element identifiers. This, I believe, was the core of your problem. Fourth, you''re not actually showing any response: your showResponse method takes only info from the local page, not the AJAX response. You might want to rename it. Fifth, just in case: the url *does* point to the same domain as the one your page comes from, right?> function showResponse() { > var inputName = $F(''firstname''); > var results = $(''contactformholder''); > results.innerHTML = ''<p><br>Thank you <br>'' + inputName + ''</p>'' > }OK, $F(''firstname'') won''t work outside IE because your field, in your HTML, has no id="firstname". It only has the (admittedly necessary) name= attribute. Second, prefer Prototype''s update() method extension to manual innerHTML manipulation; it''s more cross-browser: function replaceForm() { $(''contactformholder'').update(''<p><br/>Thank you<br/>'' + $F(''firstname'') + ''</p>''); } Aside from these, your HTML skills could, when you have some time for it, use serious upgrading. Going XHTML strict would be the first step, then caring about accessibility would be very nice. In your current form, for instance, there is no way to submit the form other than actually clicking your button (hitting Return in fields won''t do), and if JS is disabled, there''s no way at all! ''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 -~----------~----~----~----~------~----~------~--~---