Hi, I have before been using postBody to post data from browser to server. However, I noticed in some examples that parameters is used more frequently. So all is working fine, the "pars" variable is containing the expected string, and the ajax request is working fine. the updateTestOK() function is alert()-ing the responseText. But in what way do I (in my script) retreive these parameters? This might be OT as this is about the response. But is the parameters sent by POST or GET or some other way? In my PHP I am printing $_POST and $_GET but the expected content is not there. Any trivial mistake I am doing here? I don''t think this is actually related to the javascript functions that I have, because they work as they should. function updateTest () { var success = function(t) {updateTestOK(t);} var failure = function(t) {updateTestFail(t);} var url = "index.php?action=plugin&subaction=updateplugin"; var pars = Form.serialize(''testform''); var req= new Ajax.Request(url, {method: ''post'', parameters:pars, onSuccess: success, onFailure: failure}); } function updateTestOK(t) { alert(t.responseText); } function updateTestFail(t) { alert("updateTest failed"); } Best regards, Peter --~--~---------~--~----~------------~-------~--~----~ 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, tronen a écrit :> But in what way do I (in my script) retreive these parameters? This > might be OT as this is about the response. But is the parameters sent > by POST or GET or some other way?By default, A.R uses post, so in PHP you''d use $_POST. If you specify the method: ''get'' option, you''ll use $_GET...> var url = "index.php?action=plugin&subaction=updateplugin"; > var req= new Ajax.Request(url, {method: ''post'', parameters:pars,OK, you''re mixing GET and POST parameters, which works but is not very good practice. So you''re saying that on this call, the contents of the pars variable does not show in $_POST? Or are you saying that the URL-passed parameters do not show in $_GET? This latter case would not surprise me too much, after all, you ARE using POST as an HTTP method. -- 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 -~----------~----~----~----~------~----~------~--~---
Btw, I just found the problem just after submitting it. I had the select name as <select name="testvalue"> intead of <select name="testvalue[]"> That solved it. And I am back using postBody instead. But then I would like to know, what is the benefit of using parameters instead of postBody? /Peter --~--~---------~--~----~------------~-------~--~----~ 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, tronen a écrit :> But then I would like to know, what is the benefit of using parameters > instead of postBody?1) it''s a unified way of passing parameters, regardless of whether you use get or post. 2) it lets you pass an anonymous object or Hash, so you don''t have to manually encode your stuff when you would have to (typically, when you don''t rely on Form.serialize or Field.serialize). -- 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 -~----------~----~----~----~------~----~------~--~---