$.post(...) Ajax action does not return action data on server

Dear Board,

I created a plugin which uses jQuery Ajax calls ($.post(...)) to load data using actions. All actions are registerd properly in my start.php. I'm also sending the necessary ts and token. Everything works fine when I'm working on my local xampp installation. When I execute the same call on my server it just returns the dashboard page (even if I only put an 'echo "test"' in the action file). When I call the script directly using $vars['url'].'mod/xxx/actions/action.php' as address in $.post it works fine, but I think this is a security issue than. All other actions and the site work fine!

Any suggestions / ideas are welcome!


  • Can you post some code or link to a pastebin.com post?  Like pictures, code is worth a thousand words ;)

  • OK, here you go. This is the script I have on my view page:


    And here is the code of the php file


    I also included

    register_action("v-share/test",false,$CONFIG->pluginspath . "v-share/actions/test.php");

    in the init function of my start.php

    On my XAMPP this alerts "foo" correctly. On my production server (linux, apache2) this alerst nothing. When I look in the log of firebug it sends the request correctly. But the response is first

    Loading of sourcecode fails:: http://my.host.com/

    And than it returns the dashboard code.

    Tell me if you need any more information on this.


  • @Peter,

    I suggest that you upload your full 100% code as a "PlugIn" so that anyone who does have some spare time --> to study the code and actually be able to *execute the code and do some serious debugging will be able to do so...

    It is often very hard to debug snippets of code without seeing the *whole *picture ;-)



  • @Dhrup`De`Scoop

    I agree. But on the other hand I'm pretty sure, that the code in the plugin is alright, because it works without any problems on my local XAMPP installation. I'll do some research if there are any issues regarding Apache/mod_rewrite/Ajax. If I can't solve it I'll post the plugin.


  • @Peter...

    How long is a piece of string ? I Gotta see the string first ! Surely you must agree.. no one can debug code which they cannot see and and read and test-run... ;-) Sometimes another set of eyes can spot bugs quicker.. ;-)

  • The first thing you want to check is if the browser making the ajax call is logged into Elgg. 


    register_action("v-share/test",false,$CONFIG->pluginspath . "v-share/actions/test.php");

    The second parameter is restricting this to only logged in users, so if the ajax call is from a non-logged in user, it will redirect it to the dashboard page.

    Next, I would check if that is returning anything by not using a JSON call and just making a standard $.post() call and seeing what is returned.

  • Hey Brett,

    thanks for your comment. I'll check back on this later. Just moving on and use the full path to the action for now.


  • Hi furturmat,

    I have the exact problem. Have you fixed it so far?

    Thank you in advance.

  • hey futurmat, this is abhishek and i am using ajax as you mentioned above for deletion of a discussion comment but there is "undefined" response coming and page is not being called where i have written the query for deletion.....Please help me....and tell me if you need any more information regrarding this....

  • Hi abbhisekh,I cant help you until I see the code but if you wanted to see a very nice implementation of ajax,then download latest trunk version of elgg 1.8 and have a look at the messageboard plugin.You should have solved your problem after that.