我正在使用直接Web Remoting (DWR) JavaScript库文件,只在Safari(桌面和iPad)中得到一个错误
它说
超过最大调用堆栈大小。
这个错误到底是什么意思,它是否完全停止处理?
Safari浏览器也有任何修复(实际上是在iPad Safari上,它说
JS:执行超时
我认为这是相同的调用堆栈问题)
我正在使用直接Web Remoting (DWR) JavaScript库文件,只在Safari(桌面和iPad)中得到一个错误
它说
超过最大调用堆栈大小。
这个错误到底是什么意思,它是否完全停止处理?
Safari浏览器也有任何修复(实际上是在iPad Safari上,它说
JS:执行超时
我认为这是相同的调用堆栈问题)
当前回答
dtTable.dataTable({
sDom: "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
"processing": true,
"serverSide": true,
"order": [[6, "desc"]],
"columnDefs": [
{className: "text-right", "targets": [2, 3, 4, 5]}
],
"ajax": {
"url": "/dt",
"data": function (d) {
d.loanRef = loanRef;
}
},
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var editButton = '';
// The number of columns to display in the datatable
var cols = 8;
// Th row element's ID
var id = aData[(cols - 1)];
}
});
在上面的数据函数中,我使用了相同的名称d.loanRef = loanRef,但没有创建变量loanRef,因此递归地声明了自己。
解决方案:声明一个loanRef变量,或者更好的是,使用与d.loanRef不同的名称。
其他回答
我在这里还面临着类似的细节问题 上传logo时使用下拉logo上传框
<div>
<div class="uploader greyLogoBox" id="uploader" flex="64" onclick="$('#filePhoto').click()">
<img id="imageBox" src="{{ $ctrl.companyLogoUrl }}" alt=""/>
<input type="file" name="userprofile_picture" id="filePhoto" ngf-select="$ctrl.createUploadLogoRequest()"/>
<md-icon ng-if="!$ctrl.isLogoPresent" class="upload-icon" md-font-set="material-icons">cloud_upload</md-icon>
<div ng-if="!$ctrl.isLogoPresent" class="text">Drag and drop a file here, or click to upload</div>
</div>
<script type="text/javascript">
var imageLoader = document.getElementById('filePhoto');
imageLoader.addEventListener('change', handleImage, false);
function handleImage(e) {
var reader = new FileReader();
reader.onload = function (event) {
$('.uploader img').attr('src',event.target.result);
}
reader.readAsDataURL(e.target.files[0]);
}
</script>
</div>
CSS.css
.uploader {
position:relative;
overflow:hidden;
height:100px;
max-width: 75%;
margin: auto;
text-align: center;
img{
max-width: 464px;
max-height: 100px;
z-index:1;
border:none;
}
.drag-drop-zone {
background: rgba(0, 0, 0, 0.04);
border: 1px solid rgba(0, 0, 0, 0.12);
padding: 32px;
}
}
.uploader img{
max-width: 464px;
max-height: 100px;
z-index:1;
border:none;
}
.greyLogoBox {
width: 100%;
background: #EBEBEB;
border: 1px solid #D7D7D7;
text-align: center;
height: 100px;
padding-top: 22px;
box-sizing: border-box;
}
#filePhoto{
position:absolute;
width:464px;
height:100px;
left:0;
top:0;
z-index:2;
opacity:0;
cursor:pointer;
}
在修正之前,我的代码是:
function handleImage(e) {
var reader = new FileReader();
reader.onload = function (event) {
onclick="$('#filePhoto').click()"
$('.uploader img').attr('src',event.target.result);
}
reader.readAsDataURL(e.target.files[0]);
}
控制台的错误:
我解决了它通过删除onclick="$('#文件照片').click()"从div标签。
这意味着在代码的某个地方,您正在调用一个函数,该函数又调用另一个函数,以此类推,直到达到调用堆栈限制。
这几乎总是因为递归函数的基本情况没有得到满足。
查看堆栈
考虑这段代码…
(function a() {
a();
})();
下面是几次调用后的堆栈…
正如您所看到的,调用堆栈不断增长,直到达到极限:浏览器硬编码的堆栈大小或内存耗尽。
为了修复它,确保你的递归函数有一个基本情况,能够满足…
(function a(x) {
// The following condition
// is the base case.
if ( ! x) {
return;
}
a(--x);
})(10);
我们最近添加了一个字段的管理网站,我们正在工作- contact_type…简单的对吧?好吧,如果你调用select“type”,并试图通过jquery ajax调用发送它,它会失败,这个错误深埋在jquery.js中。
$.ajax({
dataType: "json",
type: "POST",
url: "/some_function.php",
data: { contact_uid:contact_uid, type:type }
});
问题是,type:type -我相信是我们将参数命名为“type”-有一个名为type的值变量不是问题。我们将其更改为:
$.ajax({
dataType: "json",
type: "POST",
url: "/some_function.php",
data: { contact_uid:contact_uid, contact_type:type }
});
并相应地重写了some_function.php——问题解决了。
对我来说 我错误地分配了相同的变量名,并给val函数“class_routine_id”
var class_routine_id = $("#class_routine_id").val(class_routine_id);
应该是这样的:
var class_routine_id = $("#class_routine_id").val();
在Angular中,如果你使用mat-select并且有400多个选项,可能会出现这个错误 https://github.com/angular/components/issues/12504
你必须更新@angular/material版本