[ad_1]
Trying to retrieve ajax data to a variable in jquery from an ajax call with a when call. But the data is as I understand not completed ajax data. Gives response in object form below where I can’t access the data under responseJSON.
{readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function, …}
//jQuery code calling the function with ajax
jQuery(document).ready(function() {
var response = ajaxcall();
console.log(response);
});
//function
function ajaxcall(){
return $.ajax({
url: "url",
type: "POST",
data: form_data,
dataType: 'json',
contentType: false,
cache: false,
processData:false,
beforeSend : function()
{
},
success: function(data)
{
if(data=='invalid')
{
alert("invalid data");
}
else
{
// success
return data;
}
},
error: function(e)
{
}
});
}
[ad_2]