I am developing a login page which look into LDAP and MySQL database for user authentication. The idea is to request two PHP page simultaneously, any one complete request will cancel the other one request.

Here is my code:

```
$scope.submitForm = function(username, password) {
    var ldap = $q.defer();
    var userTable = $q.defer();

    $http({
            timeout: userTable.promise,
            method: 'POST',
            url: 'crud/00loginUserTable.php',
            data: {
                username: username,
                password: password
            }
        })
        .then(function(response) {
            if (response.data.message != "ok")
                alert("Tak OK");
            else {
                sessionStorage.jwt = response.data.jwt;
                ldap.resolve();
                window.location.href = "index.php";
            }
        });

    $http({
            timeout: ldap.promise,
            method: 'POST',
            url: 'crud/00loginLDAP.php',
            data: {
                username: username,
                password: password
            }
        })
        .then(function(response) {
            if (response.data.message != "ok")
                alert("Tak OK");
            else {
                sessionStorage.jwt = response.data.jwt;
                userTable.resolve();
                window.location.href = "index.php";
            }
        });
};

```

This code actually works. BUT...

There is 1.3 minute delay before `window.location.href = "index.php";` could be execute. As I found out, it is something to do with PHP. I tried changing `window.location.href = "index.php";` to `window.location.href = "index.html";`. Viola! No delay. So it seems the `index.php` is waiting for `00loginLDAP.php` to timeout before responding.

I know the problem, but I don't know the solution.

Please help.