lundi 8 octobre 2018

add a laravel object captcha in javascript script

i need to add my captcha in a pop up but there are some stuff that need to be handled. first of all as i get the captcha from back-end its a php class, and secondly i need to add the object in an external js script,

so far i assigned the object to a variable in my blade file as below:

 <script>
    var captchaVar = '{!! NoCaptcha::display() !!}'
</script>

and for pop up i have following code in my script file

.confirm({
                    title: 'Confirm!',
                    content: '<div class="col-xs-12">\n' +
                        '<div class="cr-item">\n' +
                        '<label class="inl-blk">security code</label>\n' +
                        '<div class="inp area inl-blk">\n' +
                        + captchaVar + '\n' +
                        '</div>\n' +
                        '</div>\n' +
                        '</div>',
                    buttons: {
                        confirm: function () {
                            $(this).submit();
                        },
                        cancel: function () {

                        }
                    }
                });

the problem is that i get NaN instead of captchaVar which should be

<div class="g-recaptcha" data-sitekey=""></div>

Aucun commentaire:

Enregistrer un commentaire