$(window).unload(function() {
$.ajax({
type: "POST",
url: "http://www.example.com/modx/saveToSession.php",
data: {
formfieldvalue1: $('[name=formfield1]').val(),
},
success: function(msg){
alert('bla');
}
});
});
session_start();
if($_POST) {
$_SESSION['formvalues'] = '';
$formvalues = array($_POST['formfieldvalue1']);
$_SESSION['formvalues'] = $formvalues;
$data['success'] = true;
} else {
$data['success'] = false;
}
echo json_encode($data);
error(jqXHR, textStatus, errorThrown)Function
A function to be called if the request fails......
$(document).ready(function() {
$(window).unload(function() {
$.ajax({
url: "[[++site_url]][[~26]]",
statusCode: {
404: function() {
alert('page not found');
},
200: function() {
alert('page found');
}
},
type: "POST",
data: {
formfielvalue1: $('[name=formfield1]').val()
},
success: function(){
alert('success');
},
error: function(){
alert('error');
}
});
});
});
[[!saveToSession]]
echo 'thisIsTheReturnvalueOfTheSnippet';
$(document).ready(function() {
$(window).unload(function() {
$.ajax({
url: "[[++site_url]][[~26]]",
statusCode: {
404: function() {
alert('page not found');
},
200: function() {
alert('page found');
}
},
type: "POST",
data: {
formfielvalue1: $('[name=formfield1]').val()
},
success: function(){
alert('success');
},
error: function(){
alert('error');
}
});
alert('Ich warte erstmal noch auf Antwort von [[++site_url]][[~26]]');
});
});async: false