Abby E
Abby E

Reputation: 584

PHP send form data not using ajax/jQuery

How would I go about submitting form data without using HTML forms.

I only need to send 1 input to example.php, and would like stay away from ajax/jQuery.

Also is it possible to send it in the background without redirecting/refreshing the page.

The code below is as far as I have gotten. I would like it to send input_1 and it's value value 1 once the page loads to example.php without the page redirecting.

theForm = document.createElement('form');
theForm.action = 'example.php';
theForm.method = 'post';
newInput1 = document.createElement('input');
newInput1.type = 'hidden';
newInput1.name = 'input_1';
newInput1.value = 'value 1';

Upvotes: 2

Views: 192

Answers (1)

Samy
Samy

Reputation: 632

I think Jquery works fine with the devices which supports Javascript. However you can stick to the traditional xmlhttprequest. check out the tutorial.

http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp

Upvotes: 1

Related Questions