title: How to pass data via AJAX - Elgg
body: <p>How can I go about passing data from one php file to another via AJAX in Elgg?</p>
  
  <p>data_from_here.php</p>
  
  <pre><code>&lt;?php
  
      $entity = elgg_extract('entity', $vars, FALSE);
      $guid = $entity -&gt; guid;
  
      require_js('javascript_file.js');
  </code></pre>
  
  <p>javascript_file.js</p>
  
  <pre><code>require(['elgg/Ajax'], Ajax =&gt; {
  
      var ajax = new Ajax();
  
      $('.glyphicon-zoom-in').click(function(event) {
          ajax.view('my_app/data_to_here', {
              data: {
                  // I would like to pass $guid from data_from_here.php to guid here,
                  // so that js_guid will be == $guid from data_from_here.php
                  js_guid: $guid // Save the $guid from data_from_here.php in here
              },
          }).then(body =&gt; {
              $( '.full-image-view' ).html(body);
          })
      });
  });
  </code></pre>
  
  <p>data_to_here.php</p>
  
  <pre><code>// This is the file called by AJAX in javascript_file.js
  // I would like to echo $guid from data_from_here.php here
  // How do I get it from javascript_file.js
  &lt;?php
  
      echo '&lt;div class="full-image-view"&gt;$js_guid&lt;/div&gt;';
  </code></pre>