切换到https后,阻止表单/ API调用的原因是什么?

时间:2018-09-30 22:25:28

标签: javascript rest

我们已经安装了Drupal 7,并且用户可以使用一个REST表单来提交电子邮件,该REST可以正常工作,直到将网站重定向到https。如果我不强制使用https,则该表单可以正常工作-因此,我认为它与将表单尝试发布的网站列入白名单无关。

我已经尝试了许多纠正措施,但是该表格不会提交。最初,我认为在操作中删除http并替换为适当的https引用是可行的,然后我尝试了以下代码的变体,例如忽略了不安全的站点引用,没有任何作用。

使用控制台日志后,单击“提交”按钮后,该帖子:跨域请求被阻止:“同源策略”不允许读取https://secure3.convio.net/prkorg/siteCRConsAPI?luminateExtend=1.7.1&api_key= ******&method = getLoginUrl&response_format = json&v = 1.0的远程资源。 (原因:CORS标头“ Access-Control-Allow-Origin”缺失)。 >因此,我尝试通过在iis6中添加安全站点URL来允许这样做,但是仍然不允许它通过。在帖子中,我唯一更改的是星号的密钥(尽管除非有人将其列入白名单,否则我并不认为这很重要?)。

下面是我的代码:

    <!-- LuminateExtend for Survey Submission -->
    <script src="//cdnjs.cloudflare.com/ajax/libs/luminateExtend/1.8.1/luminateExtend.min.js"><

    /script>

    <!-- Luminate API Examples - Using Survey Form -->
    <script>
    (function($) {
    /* defines init variables for organization */
    luminateExtend({
    apiKey: '********',
    path: {        
    nonsecure: 'http://prkorg.convio.net/site/',
    secure: 'https://secure3.convio.net/prkorg/site',
   }
   });

   $(function() {
    /* UI handlers for the Survey example */
    // if($('.survey-form').length > 0) {
    //   $('.survey-form').submit(function() {
    //     $(this).hide();
    //     $(this).before('<div class="preFooter-success"><p>' +
    //                      'Thank you for subscribing!' +
    //                    '</p></div>');
    //   });
    // }

    /* example: handle the Survey form submission */
    /* if the Survey is submitted succesfully, display a thank you message 
    */
    /* if there is an error, display it inline */
    window.submitSurveyCallback = {
    error: function(data) {
      $('.survey-form').append('<div class="email-error-message">' +
        data.errorResponse.message +
        '</div>');
      $('.survey-loading').remove();
      $('.survey-form').show();
    },
    success: function(data) {
      console.log(data, "SUCCESS")
      if (data.submitSurveyResponse.success == 'false') {
        $('.survey-form').append('<div class="email-error-message">' +
          'There was an error with your submission :( Please try again.' +
          '</div>');
        var surveyErrors = luminateExtend.utils.ensureArray

    (data.submitSurveyResponse.errors);
        $.each(surveyErrors, function() {
          if (this.errorField) {
            $('input[name="' + this.errorField + '"]').closest('.form-group')
              .append('<div class="email-error-message">' +
                this.errorMessage +
                '</div>');
          }
        });
        $('.survey-loading').remove();
        $('.survey-form').show();
      } else {
        $('.survey-form').hide();
        $('.survey-form').before('<div class="preFooter-success"><p>' +
          'Thank you for subscribing!' +
          '</p></div>');
      }
    }
    };

    /* bind any forms with the "luminateApi" class */
    luminateExtend.api.bind();
    });
    })(jQuery);
    </script>

    <div class="preFooter lightGrayBg">
    <div class="container">
    <div class="preFooter-description">
    <img class="preFooter-mail-icon" src="<?= $base_path . path_to_theme() ?

    >/images/pf17_mail.svg" alt="mail icon">
    <p>Subscribe to get the latest news on treatments, research and other 
    updates.</p>
    </div>
    <form class="preFooter-form luminateApi survey-form" method="POST" 

    action="https://www3.parkinson.org/site/Survey" data-luminateApi='{"callback": 

    "submitSurveyCallback", "requiresAuth": "true"}'>
    <input type="hidden" name="method" value="submitSurvey">
    <input type="hidden" name="survey_id" value="formidishere">
    <label for="">Email Address</label>
    <div class="preFooter-fieldset">
    <input class="preFooter-form-input" type="email" name="cons_email" 

    id="survey-cons-email" required>
    <input type="hidden" name="cons_email_opt_in" value="true">
    <button class="preFooter-form-submit" type="submit">Sign Up</button>
    </div>
    </form>
    </div>
    </div>

能否请您推荐如何解决此问题,或者如果您看到问题来说明什么不匹配?

0 个答案:

没有答案