2012-04-06 43 views
1

大家好,並首先感謝的一切,以及這裏的問題:jQuery的對話和Ajax麻煩

每次點擊提交按鈕,我用jQuery的努力使一個Ajax請求打開鏈接在模態模式對話框了jQuery這麼想的執行,我一定是做錯了,但似乎無法找到它,這裏是代碼:

HTML

<html xmlns="http://www.w3.org/1999/xhtml" charset="utf-8"> 
<head>  
    <title>Administrador :: Estructuras M&amp;M ::</title> 
    <link href="../CSS/admin.css" rel="stylesheet" type="text/css"/> 
    <link href="../CSS/jquery-ui.css" rel="stylesheet" type="text/css"/> 
    <script src="../js/jquery-1.7.2.js" type="text/javascript"></script> 
    <script src="../js/jquery-ui.js" type="text/javascript"></script> 
</head> 
<body> 
    <div class="container"> 
     <div class="login"> 
      <form method="post" id="ingreso" name="ingreso"> 
       <div><label class="etiqueta">Usuario:</label><input type="text"  maxlength="15" id="usuario" name="usuario" /></div> 
       <div><label class="etiqueta">Clave:</label><input type="password" maxlength="15" id="clave" name="clave" /></div> 
       <div><input type="submit" value="Aceptar" id="verificar" /></div> 
      </form> 
     </div> 
    </div> 
</body> 

這是Jquery的IM試圖執行:

$('#verificar').click(function() 
     { 
      var xmlhttp; 

       try 
       { 
        xmlhttp = new XMLHttpRequest(); 
       } 
       catch(e) 
       { 
        try 
        { 
         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
        } 
        catch(e) 
        { 
         try 
         { 
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
         } 
         catch(e) 
         { 
          alert("Su navegador no soporta AJAX, por favor pruebe con otro."); 
          return false; 
         }       
        } 
       } 
       if(xmlhttp) 
       { 
        var dialog = $("<div id='modal' class='cargando' title='Verificando Usuario por favor espere.'><span>Verificando la existencia del usuario por favor espere.</span></div>").appendTo('body'); 

        dialog.dialog(
        { 
         height: auto, 
         modal: true, 
         buttons: { "Ok": function() { $(this).dialog("close");} }, 
         draggable: false, 
         resizable: false, 
         close: function(event, ui) 
         { 
          dialog.remove(); 
         } 
        }); 
       }    
     }); 

我真的希望使它工作的權利,所以我向所有人開放式的建議,謝謝。

哦,以後我打開我應該給AJAX信息發送到PHP頁面,以驗證該用戶是否存在,只是因爲我是第一個出來測試它沒有完成它的模式,

+1

試$(「#verificar」)。點擊(函數()...等 – riso 2012-04-06 16:48:31

回答

1
$('input.verificar') 

是一個選擇器,它正在查找'verificar'的的輸入。你想要的是找到一個對象,其中有'verificar'的id

$('#verificar') 
+0

喜的朋友,我改變了jQuery來檢查該ID,但它仍然產生相同的效果,它只是驗證如果它被點擊,但之後不做任何事情。 – 2012-04-06 22:08:36