IE 10返回带有JSON响应的JS标记

时间:2014-11-05 22:26:03

标签: javascript php jquery json internet-explorer

我正在针对LDAP Active Directory运行用户名和密码,Chrome中的一切正常,但IE中却没有。

我的loginform.php将gET数据提交给login.php,然后收到JSON编码的响应(或至少它应该是)

问题是它收到的响应包括一个随机的JS标签,该标签在代码中的任何地方都不存在......

loginform.php - 包含在JS标记中

    $(document).ready(function() {
    $('#loginpanel form .btn').click(function() {
        var formdatau = $('#loginpanel form').find('input[name="username"]').val();
        var formdatap = $('#loginpanel form').find('input[name="password"]').val();

        $(this).removeClass('btn-primary').addClass('btn-info').text('Loading');

        $.getJSON('login.php', { username: formdatau, password: formdatap }, function(obj) {
            if(obj.response == 'success') {
                document.cookie="auth="+obj.user;
                $('#loginpanel form .btn').removeClass('btn-info').addClass('btn-success').text('Success');
                location.href='index.php';
            }
        });
    });
});

login.php - 收到用户名和密码,然后针对LDAP运行并编码JSON响应

<?php
include('functions.php');

$_GET['username'] = strtoupper($_GET['username']);

$ldap_columns = NULL;
$ldap_connection = NULL;
$ldap_password = 'testpassword';
$ldap_username = 'CN=dom-service-mgr-svc,OU=Service Accounts,OU=Special Users,DC=HCHC';


    $ldap_connection = ldap_connect($set['ldaphost']);

if (FALSE === $ldap_connection){
}

ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); 

if (TRUE !== ldap_bind($ldap_connection, $ldap_username, $ldap_password)){
}


$ldap_base_dn = 'DC=hchc';
$search_filter = "(&(name=".$_GET['username']."))";
$result = ldap_search($ldap_connection, $ldap_base_dn, $search_filter, array('distinguishedname'));
if (FALSE !== $result){
    $entries = ldap_get_entries($ldap_connection, $result);
    if ($entries['count'] > 0){
        $userdn = $entries[0]['distinguishedname'][0];
        $pass = $_GET['password'];
    }
}


$dobind = ldap_bind($ldap_connection, $userdn, $pass);
if($dobind) {
    $resp = 'success';
} else {
    $resp = 'failure';
}

$resp = array('response'=>$resp,'user'=>$_GET['username']);
echo json_encode($resp);
?>

我确实获得了成功响应,因此LDAP身份验证正在运行,响应格式化为JSON

<script type="javascript">

</script>
{"response":"success","user":"42033"}

以上是对IE10做出回应的内容

0 个答案:

没有答案