Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » [solved] jquery.ajax question (retrieving data values on )

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

Page: 1
Go to End
Author Topic: 349 Views
  • Bimble
    Avatar
    Community Member
    16 Posts

    [solved] jquery.ajax question (retrieving data values on ) Link to this post

    How do I pull out the ajax data from the Controller action?

    The documentation "autocomplete" example seems to suggest using $request->getVar('varname'), but that's not working for me...

    javascript

    (function($) {
    $(document).ready(function(){
    kpi_data_request(1);
    })
    })(jQuery);

    function kpi_data_request(id) {
    jQuery.ajax({
    type: "POST",
    url: "/ChartKPI_Contoller/send_data",
    data: {
    "js": true,
    "id": id,
    },
    dataType: "json",
    success: function (dataseries) {
    {alert(dataseries)}
    },
    error: function (xmlhttp) {
    {alert('bad')}
    },
    });
    }

    Conroller

    public function send_data($request) {
    $id = $_REQUEST['id'];
    return json_encode("id:".$id);
    }

    Solution: I must have been sleeping: "$id = $_REQUEST['id']"

    349 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.