2012-07-17 70 views
4

返回一个字符串,当我从我的代码执行以下错误:微软JScript运行时错误:无法完成,由于操作错误80020101.错误错误阿贾克斯问题80020101从请求

以下链接为i#2发现了什么东西:Ajax request problem: error 80020101

var div = $("<div class='modal'>").html($(result.getWebFormDesignFieldContentsResult)); 

在信息传递,result.getWebFormDesignFieldContentsResult是HTML和JavaScript的长字符串未解析成DOM呢。我发现这很奇怪,因为我有一天工作,然后试图添加额外的功能....打破它。 :(

中传递的字符串是相当大的,而且是值得的喜欢:

<div>input tags for filtering</div> 
<select><option></option>...[150 option tags]... </select> 
<anchor tag to return contents> 
<script type = "text/javascript"> 
    ...stuff fires related to the above items... 
</script> 

我想它是一种具有以作为字符串传递的信息的问题被放到div标签因为它可能不喜欢脚本标记

其他人已经完成了这个,或者什么给我一些指针如何处理这个?我可能想创建一个字符串对象,然后相应地分解内容和只在html中放入html,然后以不同风格处理js。

结果字符串(result.getWebFormDesignFieldContentsResult)

您也可点击这里查看:http://jsfiddle.net/3kFv2/

  <table style='width:inherit;'> 
       <tr> 
        <td> 
         <input type='text' id ='queryInput' onkeypress = 'clearTimeout(timerVar); timerVar = setTimeout(function(){ fetchFieldInfo($("#queryInput").val()); },1000);' /> 
        </td> 
        <td style = 'text-align:right;'> 
         <a class = 'modalButton' id = 'queryButton' runat='server' value = 'Re-Filter' onCLick = '$("div.modal").fadeOut(); fetchFieldInfo($("#queryInput").val());'>Re-Filter</a> 
        </td> 
       </tr> 
       <tr> 
        <td colspan='2' style='margin-left:auto; margin-right:auto; text-align:center;'><select size = '20' id = 'selectList' name = 'selectList' ><option value = '1000'>Abutment Notes</option><option value = '2300'>Abutments Notes</option><option value = '2302'>Abutments Notes Maint Need</option><option value = '2301'>Abutments Notes Remarks</option><option value = '10942'>Concrete Deterioration Maint Need</option></select></td> 
       <td> 
        <div style='width:300px;height:300px;' id = 'modalInfoPanel'> 
        </div> 
       </td> 
      </tr> 
      <tr> 
       <td></td> 
       <td style='text-align:right;'> 
        <a class = 'modalButton' id = 'buttonReturnValue' value = 'Return Selected Element' onClick='$("div.modal, div.overlay").fadeOut();'>Return Selected Element</a> 
       </td> 
      </tr> 
     </table> 
     <script type = 'text/javascript'> 
      function ajaxDisplayContents(value){ 
       //alert(value.val()); 
/* 
       $('#selectList option').each(function(){ 
        return $(this).val() == ''; 
       }).attr('selected','selected'); 
*/ 
       $.ajax({ 
        type: 'POST', 
        url: WEBSERVICE_URL + '/fetchFieldInfo', 
        dataType: 'json', 
        contentType: 'application/json', 
        data: JSON.stringify({'fe_id': value.val().toString()}), 
        success: function(result, textStatus, jqXHR){ 
         $('#modalInfoPanel').html(result.fetchFieldInfoResult); 
        }, 
        error: function(xhr, status, message){ 
         $('#modalInfoPanel').html(status + ' ' + message); 
        } 
       }); 
      } 
      $('select#selectList').change(function(){ 
       ajaxDisplayContents($(this)); 
      }); 


      $(function(){ 
       $('ul li').click(function(){ clicker(this); }); 
      }); 
      function clicker(x){ 
       if($(x).next().is('li') || $(x).next().length == 0){ 
        $.ajax({ 
         type: 'POST', 
         url:, 
         dataType: 'json', 
         contentType: 'application/json', 
         data: JSON.stringify({}), 
         success: function(result){ 
          $(x).after($('<ul>').append($(result['METHODResult'])); 
          $(x).next().find('li').click(function() clicker(this); }); 
         }, 
         error: function(){ 
          alert('failed to fetch'); 
         } 
        }); 
       }else if($(x).next().is('ul')){ 
        $(x).next().slideUp(function(){ $(this).remove(); }); 
       } 
      } 
     </script> 
+0

如果你有一串HTML,你可以直接将它传递给'.html()'函数,你不必首先将它包装在一个jQuery对象中。 – 2012-07-17 14:40:26

+0

是的,我知道。我把它放在两边,我原来的方式和你说的一样。我只是在检查是否有问题。 – Fallenreaper 2012-07-17 14:41:58

+0

我们可以看到更多的代码吗?看你如何做AJAX调用等将会很有用。还包括来自AJAX响应的完整'

4

我得到了同样的错误80020101.

然后同时检查一行行的代码,我意识到我加入这两次错误:<script<script>

一旦我删除这些,错误就走开了。

因此,请仔细检查您的所有代码,特别是打开未正确关闭的代码。

+0

您似乎已经忘记了一个或两个单词......“错误地添加了(两次,这是不需要的)。 ..“你添加了什么? – Alejo 2012-11-30 13:51:07

0

在我的情况下,问题是位于某些注释行末尾的特殊字符(重音符号)。

当这些字符接近注释行的末尾时,Internet Explorer将删除其中的一些(包括换行符)并中断JavaScript代码。

// This comment line could fail because it has an accent at the end aeíou 
alert("This line probably doesn't work in IE"); 

IE就会明白这条线:

// This comment line could fail because it has an accent at the end **aealert**("This line probably doesn't work in IE"); 

我希望它帮你。