Answers.Body: <p>Thanks to Marty Wright for reporting the bug and providing a solution.</p>
  
  <p><a href="https://issues.civicrm.org/jira/si/jira.issueviews:issue-html/CRM-17965/CRM-17965.html" rel="nofollow">https://issues.civicrm.org/jira/si/jira.issueviews:issue-html/CRM-17965/CRM-17965.html</a></p>
  
  <p>The widget code generated for a contribution page fails trying to retrieve the json page data from the server. The output from http:///sites/all/modules/civicrm/extern/widget.php is:</p>
  
  <p>Fatal error: Call to undefined function drupal_add_http_header() in //sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 789</p>
  
  <p>This happens because Drupal is not booted when extern/widget.php runs, and CRM_Core_Page_AJAX::setJsHeaders() calls CRM_System_Utils_Drupal::setHttpHeader() which attempts to call drupal_add_http_header().</p>
  
  <p>To reproduce on the demo site:
  Enable the widget on the "Help Support CiviCRM!" contribution page.
  Find the javascript source url at the bottom of the generated code:
  <a href="http://dmaster.demo.civicrm.org/sites/all/modules/civicrm//extern/widget.php?cpageId=1&amp;widgetId=1&amp;format=3" rel="nofollow">http://dmaster.demo.civicrm.org/sites/all/modules/civicrm//extern/widget.php?cpageId=1&amp;widgetId=1&amp;format=3</a>
  Copy and paste the url into a browser to view what should be the json output, but instead:
  Fatal error: Call to undefined function drupal_add_http_header() in /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 789</p>
  
  <p>To fix the problem, I added a call to loadBootStrap() in CRM_System_Utils_Drupal::setHttpHeader()</p>
  
  <pre><code>  public function setHttpHeader($name, $value) {
      self::loadBootStrap(NULL, FALSE);
      drupal_add_http_header($name, $value);
    }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-05T18:07:23.573Z
Answers.Text: I'm having the same problem. Where do you add this code?
Answers.UserDisplayName: Alyx Perry
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-09T12:19:17.700Z
Answers.LastActivityDate: 2016-02-09T12:19:17.700Z
Answers.UserDisplayName: Friendswood Tech
Body: <p>I am running Drupal 7 and CiviCRM 4.7.1.  Since upgrade, my contribution widgets are not displaying properly, they just show placeholder.  I was able to recreate the issue in the sandbox.</p>
  
  <p>Console shows the following error: ReferenceError: jsondata4 is not defined</p>
  
  <p>At a loss of where to search next.  Thought it might be related to modsecurity or .htaccess, but since the sandbox experienced the same issue, not so sure anymore.</p>
  
  <p>Suggestions please...</p>
  
Tags: <civicontribute>
Title: Contribution Widget Not Displaying Properly
ThreadText: # Contribution Widget Not Displaying Properly
  
  (Asked by: username_0 on 2016-02-06)
  
  I am running Drupal 7 and CiviCRM 4.7.1. Since upgrade, my contribution widgets are not displaying properly, they just show placeholder. I was able to recreate the issue in the sandbox.
  
  Console shows the following error: ReferenceError: jsondata4 is not defined
  
  At a loss of where to search next. Thought it might be related to modsecurity or .htaccess, but since the sandbox experienced the same issue, not so sure anymore.
  
  Suggestions please...
  
  **Tags:** civicontribute
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-02-09. Score: 0 | Accepted answer
  
  Thanks to Marty Wright for reporting the bug and providing a solution.
  https://issues.civicrm.org/jira/si/jira.issueviews:issue-html/CRM-17965/CRM-17965.html
  The widget code generated for a contribution page fails trying to retrieve the json page data from the server. The output from http:///sites/all/modules/civicrm/extern/widget.php is:
  Fatal error: Call to undefined function drupal_add_http_header() in //sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 789
  This happens because Drupal is not booted when extern/widget.php runs, and CRM_Core_Page_AJAX::setJsHeaders() calls CRM_System_Utils_Drupal::setHttpHeader() which attempts to call drupal_add_http_header().
  To reproduce on the demo site:
  Enable the widget on the "Help Support CiviCRM!" contribution page.
  Find the javascript source url at the bottom of the generated code:
  http://dmaster.demo.civicrm.org/sites/all/modules/civicrm//extern/widget.php?cpageId=1&widgetId=1&format=3
  Copy and paste the url into a browser to view what should be the json output, but instead:
  Fatal error: Call to undefined function drupal_add_http_header() in /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 789
  To fix the problem, I added a call to loadBootStrap() in CRM_System_Utils_Drupal::setHttpHeader()
    public function setHttpHeader($name, $value) {
      self::loadBootStrap(NULL, FALSE);
      drupal_add_http_header($name, $value);
    }
  
  > **Comments:**
  > **username_1**: I'm having the same problem. Where do you add this code?  
  
  ---
  
  