提交我使用本教程創建一個登錄表單http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/登錄表單,而無需刷新
它會驗證對W /我們的LDAP服務器。
我有一個問題,什麼是它運行成功,即使我們甚至不知道用戶名和密碼成功綁定行
success: function(){
$('form#submit').hide(function(){$('div.success').fadeIn();});
。
如果發佈的用戶名和密碼成功綁定,有沒有辦法只運行成功?
編輯:LDAP-login.php中
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once('/web/ee_web/include/adLDAP.php');
$adldap = new adLDAP();
if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password']; // associated password
// connect to ldap server
$authUser = $adldap->authenticate($username, $password);
if ($authUser === true) {
$_SESSION['user_session'] = $username;
if(isset($_SESSION['user_session'])) {
print "ok";
}
}
else {
print "User authentication unsuccessful";
}
}
?>
我怎麼會傳遞一個字符串通通過PHP數據變量?我知道如果綁定成功,我可以在條件內設置$ data =「ok」,但不確定如何將它饋送到該jquery函數中。 – Brad 2010-03-23 19:42:58
@Brad - 無論響應文本是什麼,這都是自動成功功能的第一個參數。如果您只是回顯「ok」或錯誤消息,則此方法將起作用。你可以在這裏看到成功的方法定義:http://api.jquery.com/jQuery.ajax/ – 2010-03-23 19:47:54
添加了我用來綁定到ldap的php代碼,我打印出「ok」,對不起,如果這太過於字面意思 - 會那工作? – Brad 2010-03-23 20:00:40