'function( response ) doesn't redirect to non member form

I have some code that once you put in a valid member ID number it redirects you to the member registration form to complete signup. However, when I test a valid ID number it isn't redirecting as expected.

Here's an example of the API request and it's response - https://api.aim.org.uk/companies/23645/member_valid.

Because the member ID is active it should automatically redirect to the member registration form but it isn't moving past this screen so I'm hoping it's a straightforward fix. Code below:

        $(yes_box).on('click', function() {

            var member_id = $('.cron-job-search');
            var member_form = $('.member-form');

            $(title).text('Create your account');

            $('.member-choice').hide();
            $(member_id).show();

            jQuery("#member-id").submit(function(event){

                event.preventDefault();
                var post_url = jQuery(this).attr("action");
                var form_data = jQuery(this).serialize();

                jQuery.post( post_url, form_data, function( response ) {

                    var obj = JSON.parse(response);

                    var is_id_valid = obj.valid;
                    var username = obj.name;
                    var message = obj.message;

                    if(is_id_valid === true) {

                        $(member_id).hide();
                        $(member_form).show();

                        form_data = form_data.substring(form_data.indexOf("=") + 1);

                        var member_id_field = jQuery('#nf-field-338');
                        var member_name_field = jQuery('#nf-field-339');

                        jQuery(member_id_field).val(form_data);
                        jQuery(member_name_field).val(username);

                    }

                    else if(message) {

                        jQuery(".member-id-response").html( message + '. Login to aim.org.uk to retrieve it. Otherwise contact us via email' );

                    }

                    else {

                        jQuery(".member-id-response").html( 'This member ID is already in use by someone at your business, please email [email protected] if you’re not sure who is currently using the businesses AIM member ID.' );

                    }

                });
            });

        });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source