I am trying to insert data into my ajax requests, but it fails and I don't know why. I tried to look at the jQuery source code, but still can not find why it does not work. Any help appreciated. Here is the code:
$('#someElement').ajaxSend(function(e, req, options) {
options.data += (options.data.length > 0 ? '&' : '') + '__token=' + $('input#requestToken').val();
}).ajaxSuccess(function(e, req, options, data) {
if (data.nextToken) {
$('input#requestToken').val(data.nextToken);
delete data.nextToken;
}
});
The answer is as follows:
{
"response":
{
"code":0,
},
"nextToken":"4ded26352b3d44"
}
A typical query would be, for example:
$.getJSON(url, {something:'value'}, function(data) {
if (data.response.code != 0) {
}
});
The problem is that the data sent is " something=value"; Modified is datanot sent.
** EDIT **
Current request data
something: value
and should be
something: value
__token: 4ded288eec1f56
In the event callback ajaxSend, if after changing it I print the value options.data, the value will be " something=value&__token=4ded288eec1f56", but " __token=4ded288eec1f56" not sent . Why is it not sent in the request?
, "" , ?