Alistair_1 0 Newbie Poster

i am using the below script as my basis for my ajax requests However whenever i run them i keep getting the error

Uncaught SyntaxError: Unexpected token
hr.onreadystatechange

and

Uncaught TypeError: Object [object Location] has no method 'load'
hr.onreadystatechange

Here is the code

$('#ind_login_submit').on('click', function (e) {

        var vars = $("#ind_login_form").serialize();

        var hr = new XMLHttpRequest();
        hr.open("POST", "scripts/index/ind_login_submit.php", true);
        hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        hr.onreadystatechange = function() {
            if(hr.readyState == 4 && hr.status == 200) {
                var data = JSON.parse(hr.responseText);
                for(var obj in data){
                    if(obj == "error"){
                        alert(data[obj]);

                    }else if(obj == "success"){
                        window.location = "http://localhost/site/registration_complete.php";
                    }
                }
                //location.reload();
            }
        };
        return false; 


    });

Here is the external php script

<?php
     header("Content-Type: application/json");
     session_start();
       include '../../connect.php';

    $ind_reg_firstname = $_POST['ind_reg_firstname'];
    $ind_reg_lastname = $_POST['ind_reg_lastname'];
    $ind_reg_email = $_POST['ind_reg_email'];
    $ind_reg_password = $_POST['ind_reg_password'];
    $ind_reg_terms = $_POST['ind_reg_check_terms'];
    $ind_reg_privacy = $_POST['ind_reg_check_privacy'];




            $error_array = array('success' => 'Congratulations');
            $jsonData = json_encode($error_array);
            echo $jsonData; 
            exit;



?>

Any ideas why?