Error returning Ajax in IE7

Posted by GuiPereira on Stack Overflow See other posts from Stack Overflow or by GuiPereira
Published on 2010-04-03T02:43:08Z Indexed on 2010/04/03 2:53 UTC
Read the original article Hit count: 310

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc