How to solve the issue Uncaught SyntaxError: Unexpected token ‘<‘, ” on JSON.parse in the fail function

using this method when we click on submit button need to get email from the configuration record and send email, getting error as Uncaught SyntaxError: Unexpected token ‘<‘, ”JSON.parse in the fail function

 SubmitForm: function(e) {

            jQuery('form .global-views-message').parent().remove();

            var promise = BackboneFormView.saveForm.apply(this, arguments),
                self = this;

            e && e.preventDefault();

            return promise && promise.then(
                function(success) {
                    if (success.successMessage) {
                        swal('Submitted!', success.successMessage, 'success').then(function() {
                            window.location.reload()
                        });
                    } else {
                        swal('Sorry!', 'An error occured, please try again', 'error').then(function() {
                            window.location.reload()
                        });
                    }
                },
                function(fail) {
                    fail.preventDefault = true;

                    if (fail.responseJSON) {
                        _.each(fail.responseJSON.errorMessage, function(message, field) {
                            swal('Sorry!', message, 'error').then(function() {
                                window.location.reload()
                            });
                        });
                    }
                }
            );
        },

Leave a comment

Your email address will not be published. Required fields are marked *