ajax - Laravel:有效载荷无效
问题描述
如何解决此错误-
有效载荷无效。C:..\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php#191
我在发送 ajax 发布请求时得到了它。
<input name="telephone" type="tel" value="" id="phone-number">
<button class="button" type="submit" id='sendSMS' onclick="clickFunction(event, this);">Send SMS</button>
这是我的 JS 代码-
(function() {
$('#add-announcement').on('click', '#sendSMS', function() {
$.ajaxSetup({
headers: {
'X-XSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
},
});
$.ajax({
type: 'POST',
url: window.url,
dataType: 'JSON',
success: function(data) {
// alert(data);
},
error: function(jqXHR, textStatus, errorThrown) { // What to do if we fail
console.log(
'AJAX error: ' + textStatus + ' : ' + errorThrown);
},
});
return false;
});
})();
解决方案
问题解决了,问题出在axaj查询中,查询不正确。