Using variables within ajax success function that were set before ajax call (JQuery)
I spent several hours trying to access variables that were set before an Ajax call, turns out there is a simple solution. To be able to access the variables you need to set them as parameters within the Ajax call and then to access them in the success function you prefix them with "this." eg. var a = 1; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "theurl.com", data: '{a: a}', dataType: "json", a: a, success: function (msg) { var arr = eval(msg.d); process(arr, this.a ); } });