Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to have a controller action return ONLY raw data?


Go to End


2 Posts   2058 Views

Avatar
ck_bullet

Community Member, 16 Posts

8 September 2010 at 5:18am

I want to have a jquery function use ajax to return only the raw data from a controller action. If I have an alert() statement in the onsuccess function of a $.post() call to alert the return data it spits out the entire html document. How can I only have it return an array of data?

Avatar
Willr

Forum Moderator, 5523 Posts

8 September 2010 at 5:01pm

The easy no frills way is to do something like this..

// .. your controller function
echo "Some String";
die(); // or exit() or whatever to prevent loading SS templates

The other option is to use renderWith() on that function and have a empty template or one which contains just the information you want to pass back.