2010-04-03 53 views
2

這是我的第一個問題。首先,對不起我的'不完美'英語...在IE7中返回Ajax時出錯

我正在開發一個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將值返回到標籤中,有時不會。我必須不斷提交才能獲得回報。

任何人都可以幫忙嗎?

+0

沒有人可以幫助IE7。它無法修復。 – bzlm 2010-04-04 21:12:43

回答

0

您是否禁用了緩存?

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

該屬性置於控制器類中,禁用緩存。因爲我不需要在我的應用程序緩存,我把它放在我的BaseController類:

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

這裏是關於OutputCacheAttribute很好的說明:Improving Performance with Output Caching

檢查是否禁用刪除的問題。

+0

Thaks LukLed,現在工作正常.... – GuiPereira 2010-04-05 13:29:22