By LAC Webadmin on Saturday, 13 June 2015
Posted in Technical Issues
Likes 0
Views 631
Votes 0
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
Hi Arlex,

I'm good, I found the issue Mark gave me a tip on how to find ajax response.

Thanks,

Jackson
·
Wednesday, 17 June 2015 10:50
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jackson,

I am really sorry for the delay of this reply as it is a weekend for us here.

Can you provide us with your following detail?
#1. Joomla backend access
#2. FTP access
#3. How to replicate this error? If can guide us step by step since this is your custom work.
#4. Provide us your custom work file location

Looking forward of your response.
·
Sunday, 14 June 2015 21:26
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jackson,

Yes, you can see the ajax response from the browser console.

By the way, thanks for getting back to us you found the issues.

I will mark this thread as resolved and lock it to avoid any confusions in the future, but if you need any help please feel free to start a new thread in our forums.
·
Wednesday, 17 June 2015 16:34
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post