I'm trying to get a value from my data array in the beforeSend
function, but when I try to display it in the console all I see is undefined
.
I tried printing the $(this)
variable which also returns undefined
.
$("form").submit(function(){
var data = {
"action": $(this).attr("id")
};
data = $(this).serialize() + "&" + $.param(data);
$.ajax({
type: $(this).attr("method"),
dataType: $(this).data("type"),
url: $(this).attr("action"),
data: data,
beforeSend: function(data) {
console.log(data["action"]);
console.log($(this).attr("method"));
}
});
return false;
});
How can I read the values stored in the data array in the beforeSend
function