I am trying to use elgg.get ajax functionality to get some data from a php file.
elgg.get('<?php echo elgg_get_site_url(); ?>mod/plugin_name/load_data.php?q=' + text,{
success: function(data){
$("#span_id").html(data);
}
});
In the load_data.php file, whenever I use any elgg function (eg: current_page_url()) it says in the error log that it is undefined. Moreover, I had created a function in plugin library (which i registered and loaded in start.php) but when i use that function in load_data.php and call it using ajax, it still says that its undefined, anybody knows how do i resolve this situation? Note : I also used the regular jquery ajax functions, but as expected, got same problem.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Paweł Sroka@srokap

Paweł Sroka - 0 likes
- Deepak Sharma@callmedeepak

Deepak Sharma - 0 likes
- Evan Winslow@ewinslow

Evan Winslow - 0 likes
- Deepak Sharma@callmedeepak

Deepak Sharma - 0 likes
You must log in to post replies.Do you start the core in mod/plugin_name/load_data.php?
I'd suggest to switch to using either page handler or ajax view.
Note that in JS there's function elgg.get_site_url(), so you dont need to use PHP version.
Hey Pawel, Thanks for the reply. Got it working now. Btw, can you tell me what did you mean by : " Do you start the core in mod/plugin_name/load_data.php? ". Couldnt follow you there.
You probably forgot to include /engine/start.php.
In any case, I agree with Pawel that you should use a page handler and not point directly to a php script in your plugin directory.
What did you end up doing to make it work?
Hi Evan, sorry for late reply, was away for last two days, I used page handler as suggested by Pawel, and it worked smoothly. :)