How do I exchange informations using Ajax?

Get help using Construct 2

Post » Tue Aug 16, 2016 8:03 pm

I would like to understand how I can do to send and get informations from the server using AJAX. I don't need to make any changes on server hosted files. I also don't need to register anything in the database.

What I need:
1_ send the question number and answer that the user has chosen (e.g. user_id=1 / question_id=1)
2_ get the information about the next action (e.g. show video_id)
3_ send information when the video ends (go to question_id 2)

I'm using the action AJAX - Request URL to get data and it works. I'm also using the action AJAX - Post to URL to send the information and I'm getting error through the event "tag" error > set text to "Failed".

I really appreciate an example showing this procedures working or even a simulation.

Thanks in advance.
B
74
S
13
G
3
Posts: 995
Reputation: 7,531

Post » Thu Aug 18, 2016 2:22 pm

You use HTTP GET or POST requests to transfer information using AJAX.

Are you in control of your server code? If your GET request works, but your POST does not, then I would look at the server side code for your POST requests.

I use Java servlets to handle GET and POST requests to my server, and it goes something like this:
http://stackoverflow.com/questions/2349 ... n-servlets
or
http://www.codejava.net/java-ee/servlet ... va-servlet
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, part12studios and 8 guests