tags:

views:

50

answers:

1

Hi everybody! 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"})){ %>


<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?

A: 

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.

LukLed
Thaks LukLed, now it's working fine....
GuiPereira