2013-02-12 109 views
0

我有这个代码。它适用于谷歌铬和Firefox,但我不明白为什么它与IE 9失败。当我尝试这个网址: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'); 
    }); 

}); 
+6

你可能调用$。员额之前document.location.reload()完成。 – 2013-02-12 15:14:05

+0

你能告诉我该怎么做才能添加到我的jquerycode中吗? – user2064769 2013-02-12 15:19:57

回答

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'); 
    } 
});