Jaxel
Well-known member
I'm trying to do some simple AJAX, that records some data... this is my javascript:
Then this is my PHP code behind; which is working fine:
The issue is coming from the javascript. It executes the ajax fine, and the data gets inserted into my database... however, the code inside of the ".done()" never gets fired. For some reason, the ajax is never returning a successful response. Anyone got any ideas?
Code:
$.ajax({
url: '*****/session',
data: { url: encodeURIComponent(window.location.href) },
dataType: 'jsonp'
}).done(function(data)
{
Twitch.login({
scope: ['user_read', 'user_follows_edit', 'user_subscriptions'],
redirect_uri: '*****/authorize',
});
});
Code:
public function actionSession()
{
$ip = sprintf('%u', ip2long($_SERVER['REMOTE_ADDR']));
$url = urldecode($this->_input->filterSingle('url', XenForo_Input::STRING));
XenForo_Application::get('db')->query('
INSERT INTO EWRcanal_session (ip, url) VALUES (?, ?)
ON DUPLICATE KEY UPDATE url = VALUES(url)
', array($ip, $url));
$this->_routeMatch->setResponseType('json');
return $this->responseView('EWRcanal_ViewPublic_Session', '');
}
The issue is coming from the javascript. It executes the ajax fine, and the data gets inserted into my database... however, the code inside of the ".done()" never gets fired. For some reason, the ajax is never returning a successful response. Anyone got any ideas?