How to use the ajax to take the output from only block?

Permalink
Hi All,

I am using ajax in c5 and i am updating the block from ajax call this works fine but in this case i have to make the exit; in the php file which is called else it takes the whole sites output.

So in this case is there any way that i can use the ajax call in which i dont have to make the exit in php file called?

 
itrio replied on at Permalink Reply
itrio
A solution might be calling a script in the blocks folder directly, to avoid reaching the block by initializing the concrete5 script (index.php).

Example:
http://www.yoursite.ex/blocks/your_block/scripts/yourscript.php...

Make sure you don't restrict running this script, like it is normal to do in c5 files. Please also make sure that there are no security issues with this script, since it is easy for anyone to run this script.
savan replied on at Permalink Reply
Hi Paalgg,

Thanks for your reply, i have checked with your reply but in my case i want to update the data from the controller of the block , i mean i have one block that is having some output now in ajax seach i need the output from the same block i mean the number of results are going to change nothing else so how this can be done ?
Remo replied on at Permalink Reply
Remo
I don't think avoiding index.php is a good idea. You'll open your script for all kinds of security problems, you won't have access to all the nice helpers of concrete5 etc.

If you work with AJAX I'd recommend to use a "tool". Create a file called tool_name.php in the "tools" directory of your package" and use something like this to get the URL to the tool:

$uh = Loader::helper('concrete/urls');
$uh->getToolsURL('tool_name', 'package_name');
savan replied on at Permalink Reply
Hi Remo,

Thanks for your reply, i can create the tools file but i am having one block that is printing list of the items , now if i use the ajax with tool file so in that i have to put all the code of the block in that right?
so should i use the same block file as ajax will be better ? if i am using that in that case i have to use the exit in the funtion i am calling or any other way is better?
i am confused about what is the best way to use the ajax so please help me to get out of this