繁体   English   中英

在IE7中返回Ajax时出错

[英]Error returning Ajax in IE7

这是我的第一个问题。 首先,对我的英语不完美感到抱歉。

我正在使用AJAX开发ASP.NET MVC应用程序。

我在视图中有以下代码:

<% using(Html.BeginForm(null, "Home", FormMethod.Post, new{id="formcpf"})){ %>


<p>
   <input name="tipo" type="radio" value="GeraCPF" /> CPF 
    <input type="radio" name="tipo" value="GeraCNPJ" /> CNPJ
</p>


<p>
    <input type="submit" id="sbmt" value="Gerar" /> <br /><br />
    <span id="lblCPF" class="respostaBG"></span>
</p>

和以下Javascript来调用Ajax请求:

 $(document).ready(function() {


    $("form#formcpf").submit(function(event) {
        $(this).attr("action", $("input[@name='tipo']:checked").val());
        event.preventDefault();
        hijack(this, update_sessions, "html");

    });
});

function hijack(form, callback, format) {


    $.ajax({
        url: form.action,
        type: form.method,
        dataType: format,
        data: $(form).serialize(),
        success: callback
    });
}

 function update_sessions(result) {
    $("#lblCPF").html(result);
}

在Firefox和Chrome中可以正常工作,但在IE7中有时会将值返回到标签中,有时则不能。 我必须继续提交才能获得回报。

有人可以帮忙吗?

您是否已禁用缓存?

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]

放置在控制器类中的此属性禁用缓存。 由于不需要在应用程序中缓存,因此将其放置在BaseController类中:

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public abstract class BaseController : Controller
{

这是有关OutputCacheAttribute的不错描述: 通过输出缓存提高性能

检查禁用是否可以消除问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM