DISCLAIMER: I am asking about a specific use of this
, not what this
is used for in general. So, please no google/copy/paste speed answers (:
I have the javascript/jquery code below:
var req = {};
function getData()
{
var fromPage = 0;
var toPage = 1;
req = $.ajax({
url: "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: xmlData,
complete: onSuccess,
error: function (xhr, ajaxOptions, thrownError) {
alert("error: " + xhr.statusText);
alert(thrownError);
},
contentType: "text/xml; charset=\"utf-8\""
});
req.fromPage = fromPage;
req.toPage = toPage;
}
function onSuccess(resp) {
alert(this.fromPage);
}
I find it pretty confusing that the code is using fromPage
in two places (sorry not my code).
Does this
refer to the var declared inside of getData
or the one that is part of the req
object? Or maybe something else entirely....
Any help appreciated.