How do I send data to an external URL using AJAX POST

Get help using Construct 2

Post » Fri Dec 19, 2014 4:01 pm

Hi,

my game would need to submit a variable (game score) to an external PHP Script, which then displays the Game Score.

The external Script needs to get the data via the $_POST method.

I can not figure out how to send data via POST. It works fine with GET, but I want to avoid sending my data openly appended to an URL.

Is there a way to send data from C2 using POST?

Thank you for your help,
Boris
B
4
Posts: 4
Reputation: 208

Post » Fri Dec 19, 2014 4:16 pm

Yes you can use the AJAX "Post to URL" action.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Fri Dec 19, 2014 4:21 pm

Thanks for the fast response Ramones.
But can this be combined with a redirect? Can I POST to URL and have the browser display the resulting page as if I called the "Go to URL" action of the browser object?
B
4
Posts: 4
Reputation: 208

Post » Fri Dec 19, 2014 4:27 pm

Maybe you could return a URL and then have:
AJAX: On completed -> Browser: Go to AJAX.LastData
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Fri Dec 19, 2014 7:38 pm

unfortunately that did not work either. We ended up hand coding a work around using a custom script now. Not pretty but it gets the trick done. Thanks again for the quick help and good suggestions!
B
4
Posts: 4
Reputation: 208


Return to How do I....?

Who is online

Users browsing this forum: Fradno, Laurent and 10 guests