开发者

Error returning Ajax in IE7

开发者 https://www.devze.com 2022-12-25 18:31 出处:网络
It\'s my first question here. First of all, sorry for my \'not perfect\' english... I\'m developing an ASP.NET MVC application with AJAX.

It's my first question here. First of all, sorry for my 'not perfect' english...

I'm developing an ASP.NET MVC application with AJAX.

I have the following code in the View:

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


开发者_C百科<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>

and the following Javascript to call an Ajax request:

 $(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);
}

in Firefox and Chrome works fine, but in IE7 sometimes returns the value into the label, sometimes not. I have to keep submiting to get the return.

Anyone could help?


Do you have caching disabled?

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

This attribute, placed in controller class, disables caching. Since I don't need caching in my application, I placed it in my BaseController class:

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

Here is nice description about OutputCacheAttribute: Improving Performance with Output Caching

Check if disabling removes the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消