Hi There,
Sorry, I posted this in the ticketing system but I thought other users might need it as well and/or could be a help too.
If you can help me figure out what's wrong with the code I would greatly appreciate it. I'm getting a JSON error that reads:
Here's my JS code:
and here is the controller file the ajax is calling:
Thanks,
Jackson
Sorry, I posted this in the ticketing system but I thought other users might need it as well and/or could be a help too.
If you can help me figure out what's wrong with the code I would greatly appreciate it. I'm getting a JSON error that reads:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Here's my JS code:
EasySocial
.require()
.script('apps/fields/event/startend/content')
.done(function($) {
$('[data-giving]').addController('EasySocial.Controller.Field.Event.Startend', {
requiredEnd: 0,
dateFormat: '<?php echo $dateFormat; ?>',
allowTime: 0,
allowTimezone: 0,
yearfrom: '<?php echo $appParams->get("yearfrom"); ?>',
yearto: '<?php echo $appParams->get("yearto"); ?>',
disallowPast: 0,
calendarLanguage: '<?php echo $appParams->get("calendar_language"); ?>'
});
EasySocial.Controller(
'Apps.Giving',
{
defaultOptions:
{
"{startdate}" : "[data-giving-form-startdate]",
"{enddate}" : "[data-giving-form-enddate]",
"{filter}" : "[data-giving-form-filter]"
}
},
function(self)
{
return {
"{filter} click" : function()
{
//console.log()
EasySocial.ajax( 'apps/user/giving/controllers/giving/items' ,
{
"startdate" : self.startdate().val(),
"enddate" : self.enddate().val()
})
.done(function( item )
{
})
.fail( function( response )
{
self.setMessage( response );
});
}
}
});
// Implement the controller.
$( '[data-giving]' ).implement( EasySocial.Controller.Apps.Giving );
});
and here is the controller file the ajax is calling:
public function items()
{
// Check for request forgeries.
FD::checkToken();
// Ensure that the user is logged in.
FD::requireLogin();
// Get the ajax object.
$ajax = FD::ajax();
// get app model
$model = $this->getModel( 'Giving' );
$startDate = JRequest::getVar( 'startdate' );
$endDate = JRequest::getVar( 'enddate' );
// start and end date should never be empty
if( empty( $startDate ) || empty( $endDate ) )
{
return $ajax->reject( JText::_('APP_USER_GIVING_EMPTY_DATES'));
}
// get contributions
$items = $model->getItems( $startDate, $endDate );
$theme = FD::themes();
$this->set( 'items' , $items );
$contents = $theme->output( 'apps/user/giving/dashboard/items' );
return $ajax->resolve( $contents );
}
Thanks,
Jackson