I'm bad with titles, sorry.
I had a working ajax code, that I moved into a separate function ('sendForm') - after this it stopped working, redirects to the actual PHP and gives undefined index warnings.
I think the code will be the best explanation:
function sendForm(_type, _func) {
$.ajax( {
url: "/lib/auth.php",
type: "POST",
data: { type: _type,
js: true,
form: $('#auth_form').serialize()
},
success: _func(_result) /* This should maybe be just '_func'? Either way, same behavior */
} );
}
function loginEvent() {
/* This works if not commented
$.ajax( {
url: "/lib/auth.php",
type: "POST",
data: { type: 'login',
js: true,
form: $('#auth_form').serialize()
},
success: function(_result) {
if (_result == "true")
window.location = '/index.html';
else {
$('h4.header').removeClass('hide');
$('input[name=password]').val('');
}
}
} );*/
/* Trying to call the function, with an inline function as argument*/
sendForm('login', function(_result) {
if (_result == "true")
window.location = '/index.html';
else {
$('h4.header').removeClass('hide');
$('input[name=password]').val('');
}
}
);
return false;
}
And of course the warnings, from /lib/auth.php which shouldn't even open as a page:
Notice: Undefined index: form ...
Notice: Undefined index: type ...
Notice: Undefined index: js ...
I'm probably overlooking something, so thanks for any help.