我有一个jquery ajax代码如下:
$(document).ready(function() {
var global_arr = new Array();
$.ajax({
url: 'result.php',
type: 'post',
dataType: 'json',
success: function(data) {
$.each(data, function(key, value) {
global_arr.push(value.name);
});
alert(global_arr); //get correct value, works fine
}
}); //end of ajax function
alert(global_arr); //get null, it doesn't work properly
});
Run Code Online (Sandbox Code Playgroud)
注意提醒global_arr的行,为什么我不能从$ .ajax()函数中获取值?谢谢任何人的帮助.
我的代码是:
$user = 'test';
$password = 'testpass';
$host = '10.1.1.1';
$port = 389;
$basedn = 'dc=ci,dc=mycompany,dc=com';
$group = 'Users';
$ldaprdn = 'uid=test,dc=ci,dc=mycompany,dc=com';
$ad = ldap_connect("ldap://$host", $port);
if ($ad) {
echo "Connected" . "<br/>";
} else {
echo ldap_error($ad) . "<br/>";
}
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
// $ldapBind = ldap_bind($ad, "{$user}@{$domain}", $password); // 1.
// $ldapBind = ldap_bind($ad, $user, $password); // 2.
$ldapBind = ldap_bind($ad, $ldaprdn, $password); // 3.
// $ldapBind = ldap_bind($ad, null, null); // 4.
if ($ldapBind) …
Run Code Online (Sandbox Code Playgroud)