Sorry, I got a bit lost here. Could I give you more details on what I do:
Answering the question of Susan I don't have the javascript as a modx resource (if I undestand correctly), I only created an empy snippet and inserted the code there.
First I have the following chunk in the heater of my template:
<script type="text/javascript">
$(document).ready(function() {
$('.loginLoginButton').click(function() {
var action = 'lgn';
var form = $('.loginForm form');
var name = $( ".loginUsername" ),
password = $( ".loginPassword" ),
allFields = $( [] ).add( name ).add( password ),
tips = $( ".loginMessage" );
$.post(document.location.href, form, function(data){
try {
var jsd = $.parseJSON(data);
} catch (e) {
$('.loginForm').text(data);
}
window.location = jsd.redirect;
})
return false;
})
})
</script>
the I have the php snippet which catch all the requests above and answers on it.
<?php
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {return;}
$action = $_POST['action'];
if (empty($action)) {return;}
$res = '';
switch ($action) {
case 'lgn':
$res = $modx->runSnippet('Login');
break;
}
if (!empty($res)) {
die($res);
}
Should I put .load instead of post? Should I put the javascript code in the resouce with blank template?