我正在使用直接Web Remoting (DWR) JavaScript库文件,只在Safari(桌面和iPad)中得到一个错误

它说

超过最大调用堆栈大小。

这个错误到底是什么意思,它是否完全停止处理?

Safari浏览器也有任何修复(实际上是在iPad Safari上,它说

JS:执行超时

我认为这是相同的调用堆栈问题)


当前回答

我也面临着同样的问题 我已经通过删除在ajax上使用了两次的字段名来解决它 如

    jQuery.ajax({
    url : '/search-result',
    data : {
      searchField : searchField,
      searchFieldValue : searchField,
      nid    :  nid,
      indexName : indexName,
      indexType : indexType
    },
.....

其他回答

我们最近添加了一个字段的管理网站,我们正在工作- 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(); 

我在这里还面临着类似的细节问题 上传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标签。

在我的例子中,我使用以下方法将一个大字节数组转换为字符串:

String.fromCharCode.apply(null, new Uint16Array(bytes))

字节包含数百万个条目,这对于堆栈来说太大了。

这个问题可能是因为递归调用没有任何终止的基本条件。

就像在我的情况下,如果你看到下面的代码,我有相同的API调用方法和方法,我用来执行操作后的API调用。

const getData = async () => {
try {
  const response = await getData(props.convID);
  console.log("response", response);
 } catch (err) {
  console.log("****Error****", err);
}
};

基本上,解决方案就是删除这个递归调用。