[SOLVED] setResponseType() json data not coming through controller reply

  • Thread starter Thread starter asprin
  • Start date Start date

asprin

Guest
Member
I've an onchange event handler defined which makes an AJAX call
JavaScript:

Code:

Code:
// url points to myController/my-method
XF.ajax('GET', url, {'tid':2, 'eid':1}, function (data){
    console.log(data);
});
This is the controller method
PHP:

Code:

Code:
public function actionMyMethod()
{
    $this->setResponseType('json');

    $tid = $this->filter('tid', 'int');
    $eid = $this->filter('eid', 'int');

    $viewParams = [
        't'  => $tid,
        'e' => $eid
    ];

    return...
Read more

Continue reading...
 
Top