$ .post在IE 9中无效

时间:2013-02-12 15:12:37

标签: jquery internet-explorer-9 .post

我有这个代码。它适用于谷歌浏览器和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');
    });

});

1 个答案:

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