AJAX调用在Chrome中返回对象但在Firefox和IE中返回Null

时间:2013-07-26 20:49:40

标签: php jquery ajax

我的AJAX调用在Chrome中工作正常但是当我在Firefox或IE中测试它时,我收到一个空响应。非常感谢任何帮助!

我的PHP功能:

function get_ldap_attr() {

    $lan = $_POST['lan'];
    $dn = get_site_option ( "ldapServerOU" );
    $usr = get_site_option ( "ldapServerCN" );
    $pw = get_site_option ( "ldapServerPass" );
    $addr = get_site_option ( "ldapServerAddr" );
    $ad = ldap_connect ( $addr )
        or die ( "Connection error." );
    ldap_set_option ( $ad, LDAP_OPT_PROTOCOL_VERSION, 3 );
    ldap_set_option ( $ad, LDAP_OPT_REFERRALS, 0 );
    $bind = ldap_bind ( $ad, $usr, $pw );

    if ( $bind ) {
        $SearchFor ="cn=".$lan;
            $result = ldap_search ( $ad,$dn,$SearchFor );
            $entry = ldap_first_entry ( $ad, $result );
            if ( $entry != false )  {
                $info = ldap_get_attributes ( $ad, $entry );
            }           
            $comm  = stripos ( $info['manager'][0], ',' );
                // find position of first comma in CN=Mxxxxxx,OU=Users,OU=MCR,DC=mfad,DC=mfroot,DC=org  (directReports field)
            $eq = stripos ( $info['manager'][0], '=' );
                // find position of first =
            $s_lanid = substr ( $info['manager'][0], $eq+1, ( ( $comm-1 ) - ( $eq ) ) );
                //get substring between = and comma...
            $sup = getLDAPInfo ( $s_lanid, $bind, $ad, $dn ); 
                // get supervisor's info...
            $subInfo = getLDAPInfo ($lan, $bind, $ad, $dn);
    }
    echo json_encode( array( $sup, $subInfo ) );
    die();
}

我的jQuery:

jQuery(function() {

    jQuery('#empLanId').on('blur', function() {
    var lan = jQuery('#empLanId').val(),
        data = { action: "get_ldap", lan: lan};
        jQuery.ajax({
            type: 'POST',
            url: ajaxurl,
            data: data,
            dataType: 'json',
            success: function(response) {
                console.dir(response);

                jQuery('#empName').val(response[1].fullname);
                jQuery('#empSupLanId').val(response[0].lanid);
                jQuery('#empSupName').val(response[1].fullname);
                jQuery('#empSupNumber').val(response[1].phone);
            }

        });
    });
});

0 个答案:

没有答案