Hi all:
I'm trying to use an special header for send SessionKey to server, so I added following code at body.onload():
// make sure that every ajax call provides sessionKey
$.ajaxSetup({
beforeSend: function(jqXHR,settings) {
if ( typeof(authInfo.SessionKey)!=undefined && authInfo.SessionKey!=null) {
jqXHR.setRequestHeader('X-AC-SessionKey',authInfo.SessionKey);
} else {
// no SessionKey found, do not send special header
alert("No Session Key"); // just for debug
}
return true;
}
});
This code works fine in almost $.ajax calls... but beforeSend is never invoked when I use easyui form('submit',options}.
/**
* Ask server routines for add/edit a prueba into BBDD
*/
function savePrueba() {
// take care on bool-to-int translation from checkboxes to database
$('#pruebas-Cerrada').val( $('#pruebas-Cerrada').is(':checked')?'1':'0');
// do normal submit
$('#pruebas-form').form('submit',{
url: '/agility/server/database/pruebaFunctions.php',
method: 'post',
ajax: true,
onSubmit: function(param){
return $(this).form('validate');
},
success: function(res){
var result = eval('('+res+')');
if (result.errorMsg){ $.messager.show({width:300, height:200, title:'Error',msg: result.errorMsg });
} else {
$('#pruebas-dialog').dialog('close'); // close the dialog
$('#pruebas-datagrid').datagrid('reload'); // reload the prueba data
}
}
});
}
Seems that form submit is not performed by mean of ajax call... but easyui doc says that ajax call is used by default since 1.4 version...
adding ajax:true to options doesn't affect result
So what am I doing wrong, ¿How can I generate this request header on _every_ server call?
Thanks in advance
Juan Antonio