Jump to:

3431 Posts in 1025 Topics by 864 members

Template Questions

SilverStripe Forums » Template Questions » How to have a controller action return ONLY raw data?

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

Page: 1
Go to End
Author Topic: 1038 Views
  • ck_bullet
    Avatar
    Community Member
    16 Posts

    How to have a controller action return ONLY raw data? Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: How to have a controller action return ONLY raw data? Link to this post

    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.

    1038 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.