Append parameter to url during ajax call with jQuery
Hallo, I need to append a parameter during an ajax call: I was thinking about something like below:
function initTestAjaxAppendUrl() {
jQuery(document).ajaxSend(function(evt, request, settings){
console.debug("Starting request at " + settings.url + " ")
console.debug("Data " + settings.data + " ");
settings.url = "http://www.cippa.lippa";
settings.data = settings.data + someCustomData;
});
jQuery("#testAjaxAppendUrl").click(function(){
$.ajax({
type: "POST",
url: 'http://www.google.it',
data: {param1 : "myParam1", param2 : "myParam2"},
success: function(data) {
console.debug('Load was performed.');
}
});
});
}
The problem seems to be with the ajaxSend parameters. It seems that I cannot modify none of them:
settings.data = settings.data + someCustomData does not work: are the parameters read-only?
Kind regards
Massimo