i am not able to print the parsed json file on the console outside the ajax call? what am I doing wrong?
function displayData(term) {
var frmStr =$('#input1').serialize();
var result;
$.ajax({
url:'./cgi_temp4_1.cgi',
dataType:'json',
data: frmStr,
success: function(data, textStatus, jqXHR){
//alert(data)
result = $.parseJSON(JSON.stringify(data))
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
//i get "undefined" message on the console
console.log(result);
}