How to pass data via AJAX

How can I go about passing data from one php file to another via AJAX in Elgg?



    $entity = elgg_extract('entity', $vars, FALSE);
    $guid = $entity -> guid;



require(['elgg/Ajax'], Ajax => {

    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 => {
            $( '.full-image-view' ).html(body);


// 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

    echo '<div class="full-image-view">$js_guid</div>';

This discussion is closed.

This discussion is closed and is not accepting new comments.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking