0

I am adding this file run-time

https://www.google.com/recaptcha/api/challenge?k=6Lesu9wSAAAAAJwEKDbks3whwRlywo-6oFucYU-5

It is giving me error: Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.

here is the code:

 $scope.init = function () {
    $scope.isPC = utilities.isDesktop();
    setTimeout(function () {
            signupService.initializeSignup().then(function (response) {
                if (response.data != null && response.data.success) {
                    if (response.data.normalUser.ShowCaptcha != false) {
                        $.getScript("https://www.google.com/recaptcha/api/challenge?k=6Lesu9wSAAAAAJwEKDbks3whwRlywo-6oFucYU-5").done(function (script, textStatus) {
                            $rootScope.IsCapcthaScriptAvailable = true;
                        });
                    }
                }
            });
        }, 2000);
};

Can anyone tell, how can I add this without getting this error:

Amna
  • 603
  • 7
  • 30
  • so you basically just need the object RecaptchaState filled with data? – ave4496 May 27 '16 at 10:48
  • I wanted it to be add this way. and resolved the error or if any possible way i can catch this error? – Amna May 27 '16 at 10:50
  • What's the purpose of adding it this way? – ave4496 May 27 '16 at 10:51
  • This is part of our optimization We do not add any file, which is not required SO we add it at runtime – Amna May 27 '16 at 11:03
  • Possible duplicate of [Execute write on doc: It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.](http://stackoverflow.com/questions/24297829/execute-write-on-doc-it-isnt-possible-to-write-into-a-document-from-an-asynchr) – John May 27 '16 at 11:12

0 Answers0