2
如何在不使用HTML表单的情况下提交表单数据。PHP发送不使用ajax/jQuery的表单数据
我只需要发送1个输入到example.php,并希望远离ajax/jQuery。
也可以在不重定向/刷新页面的情况下在后台发送它。
下面的代码是我所得到的。我希望它发送input_1
,它的值为value 1
一旦页面加载到example.php
没有页面重定向。
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';
支持JavaScript但不支持AJAX的设备? AJAX主要是JavaScript! – Raptor 2013-02-20 06:13:44
@ShivanRaptor即时通讯对不起,需要解决这个问题,有真正的越野车使用jQuery,所以我宁愿只是把它留在javascript – 2013-02-20 06:14:44
与重定向到example.php你不能。你应该尝试一下,如果设备通过简单的xhr请求来支持ajax。查找跨浏览器xhr。 – Prasanth 2013-02-20 06:15:36