title: Sending html code through json from php to javascript
body: <p>I am getting following error in JS:
  SyntaxError: Unexpected token &lt; in JSON at position 0</p>
  
  <p>How can I properly send HTML code (it's a whole page) through the JSON. 
  I did not made this idea, but this is the plugin that I am trying to install, and I am getting this error. So if anybody can point me out what is wrong in here and how to fix it, it would be great. Thanks.
  <a href="https://i.stack.imgur.com/VBaJq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VBaJq.jpg" alt="enter image description here"></a></p>
  
  <pre><code>    public function ajaxfilter()
  {
      $this-&gt;registry-&gt;set('bf_force_tmp_table_creation', true);
      $data = $this-&gt;_prepareFilterInitialData();
  
      $json = array();
      $route = $this-&gt;_getRequestParam('curRoute');
      if ($route &amp;&amp; $this-&gt;_getRequestParam('withContent')) {
          $this-&gt;request-&gt;get['route'] = $route;
          $this-&gt;load-&gt;controller($route, $data);
          $json['products'] = $this-&gt;response-&gt;getOutput();
      }
  
      $this-&gt;load-&gt;model('module/brainyfilter');
      $model = new ModelModuleBrainyFilter($this-&gt;registry);
  
      $model-&gt;setData($data);
  
      if ((bool)$this-&gt;_getRequestParam('count', false)) {
          $json['brainyfilter'] = $model-&gt;calculateTotals();
      }
      if ((bool)$this-&gt;_getRequestParam('price', false)) {
          $minMax = $model-&gt;getMinMaxCategoryPrice();
          $min = floor($this-&gt;currency-&gt;format($minMax['min'], $this-&gt;_currency, '', false));
          $max = ceil($this-&gt;currency-&gt;format($minMax['max'], $this-&gt;_currency, '', false));
          $json['min'] = $min;
          $json['max'] = $max;
      }
      $this-&gt;log-&gt;debug($json);
      $isMijoShop = class_exists('MijoShop') &amp;&amp; defined('JPATH_MIJOSHOP_OC');
      if ($isMijoShop) {
          header('Content-Type: application/json');
          die(json_encode($json));
      } else {
          $this-&gt;response-&gt;addHeader('Content-Type: application/json');
          $this-&gt;response-&gt;setOutput(json_encode($json));
      }
  }
  </code></pre>