Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 表单未通过Firefox提交_Html_Ajax_Forms_Laravel_Firefox - Fatal编程技术网

Html 表单未通过Firefox提交

Html 表单未通过Firefox提交,html,ajax,forms,laravel,firefox,Html,Ajax,Forms,Laravel,Firefox,我有一个表单可以在Chrome、Safari上完美运行,但不能在Firefox上运行 Try1 Try2 后果 网络选项卡 标题 Params 如何进一步调试它?您需要在表单中添加一个CSRF令牌。假设这是一个刀片文件: <form id="subscribe-form" class="footer-sign-up" action="/subscribe" method="POST"> {{ csrf_field() }} <input type="text" pla

我有一个表单可以在Chrome、Safari上完美运行,但不能在Firefox上运行

Try1 Try2 后果 网络选项卡

标题

Params


如何进一步调试它?

您需要在表单中添加一个CSRF令牌。假设这是一个刀片文件:

<form id="subscribe-form" class="footer-sign-up" action="/subscribe" method="POST">
  {{ csrf_field() }}
  <input type="text" placeholder="First Name" name="first_name" id="fname" required>
  <input type="text" placeholder="Last Name" name="last_name" id="lname" required>
  <input id="footer-email" type="text" placeholder="Your Email Address" name="email" required>
<input type="submit" id="subscribe" class="signupbtn" value="sign up">

加载Laravel中的页面时,您可以打印CSRF或跨站点请求伪造令牌,该令牌在一定时间内有效。任何POST请求都需要有一个最新的,否则Laravel会给你一个页面过期错误。

我想我可能发现了什么;如果您是通过AJAX提交的,但没有阻止页面提交,那么您将遇到问题

将部分代码更改为:

$('#subscribe').click(function(e){
  e.preventDefault();
  ...
这应该只执行AJAX提交,而不刷新页面


通过将button type=submit更改为button type=button,我还可以通过FireFox进行提交,这样它就不会在按下按钮时以本机方式提交页面。

提交时控制台中有错误吗?FireFox的调试器中有错误吗?F12应该打开它,您可以检查控制台和网络选项卡的前端/后端错误respectively@Jeff控制台看起来很干净。我收到了这个错误,页面由于不活动而过期。请刷新并重试@蒂姆·刘易斯,在“网络”选项卡中,我看到两篇帖子。1是200,1是419,将在帖子中添加屏幕截图。响应选项卡中有什么?这是正确的,但不能真正解释为什么在Chrome/Safari而不是Firefox中工作。会吗?现在进行测试,似乎面临同样的结果。第一次尝试。现在我会再做一次。我需要在我的元部分中添加这一行吗?在我的master.balde.php上?现在就试试看。@TimLewis不,它不能解释这一点。我也不能——但当我看到这个错误时我就知道了,所以我想这应该是开始的地方。
<form id="subscribe-form" class="footer-sign-up" action="/subscribe" method="POST">
  {{ csrf_field() }}
  <input type="text" placeholder="First Name" name="first_name" id="fname" required>
  <input type="text" placeholder="Last Name" name="last_name" id="lname" required>
  <input id="footer-email" type="text" placeholder="Your Email Address" name="email" required>
<input type="submit" id="subscribe" class="signupbtn" value="sign up">
$('#subscribe').click(function(e){
  e.preventDefault();
  ...