Forums

the "http request" action, send POST data to 2 different URL

chico 08 Dec, 2011
Hi!
First of all, sorry for my bad english.
Now when that i said, on to the problem.

I've been working on a form that needs the 'action' to an external page and I also need to provide the 'post' data.

So i decided to give the "http request" action a try.
What I need is to redirect the user to the external page but also send an E-mail with the POST data to the page owner.

well, setting the forms action to an external page and having the "HTTP Request URL" set to the same form url, with &event=submit it sends the data to both URL's. (according to http headers in firefox).
But i can not trigger any events.
According to the form "Response Element ID":

The id of the element which will be loaded with the response string when the request is completed with success.


Anyhow, this is mu configuration:
Events:onLoad -->
Custom Code - Preload: some PHP
Load JS - A javascript function that reads and modifies FORM data, called by "onsubmit" in the "form" tag
Show html - well oviuosly loads the form 🙄
HTTP Request - The "splitter" for my forms data
according to the help section:

Sometimes we need to submit our form to 2 different URLs, this was hard to do, the only way to do this was to use the CURL library, however, this action should allow this to be done now.
For example, set your form's action URL to PayPal, Moneybookers or SugarCRM..etc and use this HTTP Request to communicate with one of your form events, or vice versa.



Vell since I've set my "action URL" to where I want to redirect the users (with the POST data) then the "on Submit" action does not get read by Chronoforms.
I've tried looking for a manual and browsed everywhere for some info about this action, but I can not find anything useable.

I have also tried setting the "HTTP Request URL" to an other PHP file to process the data there, but it does not send the POST data when I manually set this parameter. (except for the default location), so I can not do a Workarround that way.

So, my option is to try to access a event using the "Response Element ID".
But how do I set it?
I've tried several ways but I really do not understand how to use the "Response Element ID" element.
Any ideas anyone?
I'd be most thankful

/Cristian Herrera
GreyHead 08 Dec, 2011
Hi Cristian,

I've seen that action but haven't used it. I had a quick look at the code and it appears to work like an AJAX query (I have done a few of those).

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look to see if I can work out what is happening.

I think that the Response ID is the id of an element in your page that will be updated with the result of any output from the Event you submit to i.e. the content of an echo statement or a Thank You message. I'd guess that something needs to be done to prevent the template being included though - possibly add tmpl=component to the Post output.

There may also be a problem with your use of the JavaScript onSubmit event. Both the Validation and the HTTP Request action use this - I can see that the HTTP Request action does something to block or change the Validation script but I haven't' dug deep enoguh to see exactly what is happening.

Bob
Max_admin 08 Dec, 2011
Hi,

You will need a custom code action with the code below at the END of the new event accessed using the "HTTP request" action:

$mainframe =& JFactory::getApplication();
$mainframe->close();


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
chico 13 Dec, 2011
[quote="admin"]Hi,

You will need a custom code action with the code below at the END of the new event accessed using the "HTTP request" action:

$mainframe =& JFactory::getApplication();
$mainframe->close();


Regards,
Max[/quote]

Hi Max!
Thanks for your reply.
Well, I am new to chronoforms and kind of new to the Joomla framework.
So, I would like to minimize the pitfalls.

well first of all, I am a litle confused on how to fill in the "event".
If I create an event named "Test" the system will call it "on Test".
So should I call it "Test", "onTest" or "on Test".

As for now someone moved the site to another server, and I can either access the access-log or the error-log wich cripples my debugging, so right now I am copying the site to a development server so I can "tail -f" those files and see what happens "under the hood".
Anyhow, what I want too achive is to use the data in a new action, like a send mail action or store to database.

So, how does chonoforms handle the data after I have cought the data with:

[code]$mainframe =& JFactory::getApplication();
$mainframe->close();[/code]?
I am not used to using frameworks, so I am reading the documentation as I go along.
This code looks lite it creates an Object derived from the Japlication class (according to the documetation http://docs.joomla.org/JFactory::getApplication/1.6) and then closes it.
So, does the POSTed data get available again in the chronoforms event or must I write custom code in between the $mainframe =& JFactory::getApplication(); and the $mainframe->close(); statements?

Thanks in advance /Cristian
GreyHead 15 Dec, 2011
Hi Cristian,

If I create an event named "Test" the system will call it "on Test".
So should I call it "Test", "onTest" or "on Test".


You should refer to it as 'Test' - i.e. in a url with &event=Test

I set up a trial with your form and got it working - at least partially.
[list=a]
  • I created a new event called 'test' and added a Custom Code event with some test code
    <?php
    echo 'bananas';
    $mainframe =& JFactory::getApplication();
    $mainframe->close();
    ?>

  • In the Form elements I used a Custom action to add a <div> with an id of 'response' (this is the Response ID).
    <div id='response'>Caramel</div>

  • In the Form's On Load Event I added an HTTP Request action. The HTTP Request URL is
    http://my_domain.com/index.php?option=com_chronoforms&chronoform=form_name&event=test&tmpl=component

    The Request Event was left as 'Form's OnSubmit'.
    The Response Element ID was set to 'response' (see above).
  • [/list:o]

    When I submit the form I can see that the contents of my Response div changes from 'caramel' to 'bananas' to tell me that the HTTP Request has executed.

    If you want to redirect the user with the data then you have two options: (a) use the Action URL, in which case ChronoForms on Submit event will never run or (b) let the form submit normally and then redirect the user either using the REDirect User action (if you can pass the data using Get); or with a second form using post (you can make this auto-submitting, or have it look like a confirmation).

    Tringgering actions on the JavaScript onSubmit event can be tricky as the form validation (and here the HTTP Request action) is using the event and, in my experience, the validation often blocks any other events from being triggered. Why that happens is beyond my knowledge :-(

    Bob
    This topic is locked and no more replies can be posted.