2016-07-07 11 views
0

ElggのAJAX経由で、あるファイルから別のファイルにデータを渡す方法はありますか?AJAX経由でデータを渡す方法 - Elgg

data_from_here.php

<?php 

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

    require_js('javascript_file.js'); 

javascript_file.js

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); 
     }) 
    }); 
}); 

data_to_here.php

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

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

答えて

0

だけで応答を受信するためにJSONを使用して、PHP応答にHTMLタグを使用しないでくださいそのレスポンスに応じて、必要に応じてタグを付けます。

関連する問題