i have got a javascript array which array retrieve from rest. I want to populate this array result in razor foreach. But i couldnt reach to my global array result in javascript. How can i do this ?
Here is my javascript;
function getAlarmModels(cb) {
$.ajax({
url: "SomeURL",
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: failureCb,
success: successCb,
timeout: 60000
});
function failureCb(jqXHR, textStatus, errorThrown) {
var errorCode = jqXHR.status;
var errorText = textStatus;
console.log("Error Code [" + errorCode + "]: " + errorText);
if (cb)
cb(null);
}
function successCb(data) {
window.PreviousBill = JSON.parse(data);
if (cb)
cb(JSON.parse(data));
}
}
Here is razor;
@for (int i = 0; i <window.PreviousBill.Count ; i++)
{
}
}
How can i access to "window.PreviousBill" ?