2

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';
6
  • devices that support JavaScript but does not support AJAX ? AJAX is mainly JavaScript! Commented Feb 20, 2013 at 6:13
  • @ShivanRaptor im sorry need to fix that, there real buggy using jQuery so I rather just leave it to javascript Commented Feb 20, 2013 at 6:14
  • with out redirecting to example.php you can not. You should try if the devices support ajax through simple xhr request. Look up cross browser xhr. Commented Feb 20, 2013 at 6:15
  • There is a wide selection of devices which support jQuery today. What kind of devices are you using? Commented Feb 20, 2013 at 6:18
  • @Prasanth first answer stackoverflow.com/questions/8638984/… says it can be done but I couldn't get it to work. Commented Feb 20, 2013 at 6:19

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.