Error returning Ajax in IE7
- by GuiPereira
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?