简体   繁体   English

jQuery动态表单未在移动设备上发布

[英]jQuery Dynamic form not posting on mobile

I am trying to create a form dynamically and then submitting it. 我试图动态创建一个表单,然后提交它。 I have it working on desktop browsers but on mobile Android and iOS, it does not work. 我可以在桌面浏览器上使用它,但是在移动Android和iOS上却无法使用。

What it is doing is refreshing the page and not sending the post request. 它正在做的是刷新页面而不发送帖子请求。

Here is the code: 这是代码:

var $form = $(document.createElement('form')).attr('action', '/results').attr('method', 'POST');
$form.append(form.find('input[name="_token"]'));
$form.append('<input type="hidden" name="term" value="'+term+'">');
$form.append('<input type="hidden" name="extra" value="'+extra+'">');
$form.append('<input type="hidden" name="value" value="'+value+'">');
$form.append('<button id="submitSearch" type="submit"></button>');
$($form).appendTo(document.body);
$($form).submit();

Any ideas on why it would not work on mobile browsers? 关于为什么它不能在移动浏览器上运行的任何想法?

There seemed to be an issue with Laravel not seeing the token correctly. Laravel无法正确看到令牌似乎存在问题。

I created the form in the page and set the fields in the JS. 我在页面中创建了表单,并在JS中设置了字段。 This then seemed to work. 然后这似乎起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM