我有这个代码。它适用于谷歌浏览器和Firefox,但我不明白为什么它失败了IE 9.当我尝试这个URL:Login?login_username=toto&login_password=toto
它的工作原理。所以我认为问题来自$.post
,因为当我尝试在我的应用程序中连接时,表单为空,因此$.post
不能很好地发送表单。
$(function() {
$("#dialog").dialog("destroy");
$("#dialog").dialog({
autoOpen: false,
height: 200,
width: 300,
modal: false,
buttons: {
'Se connecter': function() {
$(".ajax").trigger('submit');
},
Retour: function() {
$("#dialog").dialog('close');
}
},
close: function() {
}
});
$(".ajax").submit(
function(e) {
var login_username = $("#login_username").val(),
login_password = $("#login_password").val();
alert(login_username + " pass " + login_password);
$.post('Login',{login_username:login_username,login_password:login_password});
document.location.reload()
return false; // Pour empêcher le submit vers la page 'action'
});
$('#connect').click(function(e) {
e.preventDefault();
$('#dialog').dialog('open');
});
});
答案 0 :(得分:0)
你可以试试这个:
var values = {numberId: "1", companyId : "531"};
$.ajax({
url: "test.php",
type: "post",
data: values,
success: function(){
alert("success");
document.location.reload();
},
error:function(){
alert("failure");
$("#result").html('there is error while submit');
}
});