form for input values with ajax

Hello,i am creating a project with arduino mega and ethernet shield and i want a little help on how to make a form to send values to arduino using ajax.The form type i want is ex.(18).I am not using an SD card so the code will be on arduino.I create all the other code like web server so the only think i stuck is this.Thank you in advance.

to send values to arduino using ajax.

Why do you insist on ajax being part of the equation? A form is perfectly capable of sending data from any changed objects on the form when the form is submitted, without the use of ajax.

In any case, your question is NOT an Arduino question, and belongs on a ajax forum.

I want a form to choose about 5 values and when I press submit button to change an integer for example.I want the submit button to use ajax so when I press it not refresh page.If you have a suggestion without ajax is accepted.I know how to make a form and submit button code I dont know how to get this values.Thank you for quick reply.

Anyone can help me with this?

barakos_st:
Anyone can help me with this?

It will be much easier to learn how to do this using a program on your PC. There will be hundreds or thousands of web tutorials about ajax and forms. I like the tutorials on w3schools

When you know how to do it with your PC then it will be straightforward to convert that knowledge to an Arduino.

…R

I have read most of tutorials and I am not new with this.I cant find how submit button works to get values.The only thing I want is this.I am ok if it works without using ajax.

I cant find how submit button works to get values.

Do you really need to know how it works? Or, is it sufficient to know that it works?

The w3schools link has plenty of "Try me" examples so you can test all the form items you like, and see what the resulting GET request will look like.

I ask for the code on arduino to get the value.I have read and try the examples on w3scools but I cant understand or fix the code for that.

barakos_st:
I ask for the code on arduino to get the value.I have read and try the examples on w3scools but I cant understand or fix the code for that.

To be honest, until you can understand and replicate the w3schools stuff with your PC you are just wasting your time trying to figure out how to do it with an Arduino. It will be easier on the PC.

...R

What I'm asking is simple.In the example above the value send in a php page.I want to send it for example in a void.

What I'm asking is simple.In the example above the value send in a php page.

The example doesn't "send in" anything. It invokes a php script on the w3schools server. That PHP script does something with the GET request.

Your form (served up by the Arduino) will define what script (could be /) on what server (the Arduino which served up the page) to invoke. The Arduino will then need to serve up a response (could be the same page as when the GET request does not have a ? in it) AND do something additional if the GET request HAS a ? in it.

PaulS:
The example doesn't "send in" anything. It invokes a php script on the w3schools server.

And in case of doubt an Arduino is quite incapable of running a PHP interpreter.

...R

barakos_st:
What I'm asking is simple.

It may seem simple in your mind but I don't have a clue what you are asking advice about (and I have worked with forms and AJAX for my projects).

  • What exactly is the project you want to implement?
  • Will your Arduino be the web server or a client?
  • If the Arduino is a client then where will the server be hosted?
  • And who will be programming the server?

...R