【问题标题】:JavaScript runtime error: Could not complete the operation due to error 80020101JavaScript 运行时错误:由于错误 80020101 无法完成操作
【发布时间】:2013-11-05 17:32:50
【问题描述】:

我正在开发一个 asp.net mvc web 应用程序,我有以下主要视图:-

<div class="box-content">


@using (Ajax.BeginForm("AssignCustomer", "Firewall", new AjaxOptions

{
    InsertionMode = InsertionMode.InsertAfter,
    UpdateTargetId = "Customertable",
    LoadingElementId = "progress",
    HttpMethod= "POST",
    OnSuccess="submitform"





}))
{
    @Html.ValidationSummary(true)
     @Html.AntiForgeryToken()
    @Html.HiddenFor(model=>model.FirewallCustomer.ID)


<div>
<span class="f">Customer Name</span>


    @Html.TextBoxFor(model => model.FirewallCustomer.CustomerName, new { data_autocomplete_source = Url.Action("CustomerAutoComplete", "Firewall") })

  @Html.ValidationMessageFor(model => model.FirewallCustomer.CustomerName)




</div>


       <input type="submit" value="Save" class="btn btn-primary"/>
}
                        <p><img src="~/Content/Ajax-loader-bar.gif" class="loadingimage" id="progress" /></p>
<table  class="table table-striped table-bordered bootstrap-datatable datatable">
 <thead>
<tr>
<th class="f"> Customer Name </th>


</tr></thead>
    <tbody id="Customertable">

    @foreach(var info in Model.Firewall.FirewallCustomers.OrderBy(a=>a.CustomerName)){
        <tr id= "@info.CustomerName">


<td> @Html.ActionLink(info.CustomerName, "Index", "Customer", new {searchTerm=info.CustomerName},null)</td>
            <td></td>
        </tr>
    }
</tbody>


         </table> </div></div></div>


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

在提交 Ajax.begin 表单时调用以下操作方法:-

[HttpPost]
        [ValidateAntiForgeryToken]
        [CheckUserPermissions(Action = "Edit", Model = "Firewall")]
        public ActionResult AssignCustomer([Bind(Include = "FirewallCustomer")] FirewallJoin fc)
        {
            fc.FirewallCustomer.CustomerName = fc.FirewallCustomer.CustomerName.Trim();
            if (ModelState.IsValid)
            {
                try
                {

                    repository.InsertOrUpdateFirewallCustomer(fc.FirewallCustomer,ADusername);
                    repository.Save();

                    return View("_customerrow", fc.FirewallCustomer);

从动作方法调用返回的局部视图(应该插入到表体之后)如下所示:-

@model TMS.Models.FirewallCustomer
<tr id="@Model.CustomerName.ToString()">
    <td>@Model.CustomerName</td>



    <td>
        @Ajax.ActionLink("Delete",
 "DeleteCustomerFirewall", "Firewall",
new { firewallid = Model.ID, customername = Model.CustomerName},

new AjaxOptions
{ Confirm = "Are You sure You want to delete " + Model.CustomerName,
    HttpMethod = "Post",

    OnSuccess = "deletionconfirmation",
    OnFailure = "deletionerror"
})

    </td>
    </tr>

现在当我点击 ajax.beginform insdie 我的主视图时,记录将被添加到数据库中,但部分视图不会返回,而是我会得到以下异常:-

   0x80020101 - JavaScript runtime error: Could not complete the operation due to error 80020101.

jquery 1.8.2 会在以下代码上抛出异常(throw e):-

if ( !transport ) {
            done( -1, "No Transport" );
        } else {
            jqXHR.readyState = 1;
            // Send global event
            if ( fireGlobals ) {
                globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
            }
            // Timeout
            if ( s.async && s.timeout > 0 ) {
                timeoutTimer = setTimeout( function(){
                    jqXHR.abort( "timeout" );
                }, s.timeout );
            }

            try {
                state = 1;
                transport.send( requestHeaders, done );
            } catch (e) {
                // Propagate exception as error if not done
                if ( state < 2 ) {
                    done( -1, e );
                // Simply rethrow otherwise
                } else {
                    throw e;
                }
            }

谁能告诉我是什么导致了这个问题?

【问题讨论】:

  • 您的页面上是否有任何自定义 Javascript 代码(不是 jQuery 库本身)?如果是,那么请检查它是否有一些“意外内容”,例如对象文字中的额外逗号或脚本代码中的 HTML cmets 等。更好:向我们展示代码:-)
  • 此视图与其他页面共享相同的自定义脚本,并且这些自定义脚本在应用程序的其余部分上运行良好。
  • 好的,但这是一个 Javascript 错误...我敢打赌问题不在 jQuery 库中

标签: javascript jquery html jquery-1.8


【解决方案1】:

所有错误 80020101 意味着在评估 JavaScript 时出现了某种错误。如果您通过 Ajax 加载该 JavaScript,则评估过程特别严格。

有时删除 // 会解决问题,但反之则不正确...问题并不总是由 // 引起的。

查看 Ajax 调用返回的确切 JavaScript 并查找该脚本中的任何问题。有关更多详细信息,请参阅此处的精彩文章

http://mattwhite.me/blog/2010/4/21/tracking-down-error-80020101-in-internet-exploder.html

【讨论】:

  • 你能告诉你删除 // 是什么意思吗??
  • 在开发人员工具中检查 ajax 调用返回了哪些数据。一定有什么东西破坏了你的完整 javascript 代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-25
  • 1970-01-01
  • 2018-09-24
  • 1970-01-01
相关资源
最近更新 更多