UPDATES EasyBlog 6.0.14 Released! Joomla 5.x and PHP 8.x compatible now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is offline
It is currently off working hours and most of us aren't around

Rest assured that we will get back to you as soon as the day starts tomorrow!
  Support is offline

ES App dev getting a JSON error

LAC Webadmin · ·
12:45 AM Saturday, 13 June 2015
None
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:


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
The replies under this section are restricted to logged in users or users with an active subscription with us