I need a fresh pair of eyes on this simple bit of code, thank you.
var totalMessageCount = 0;
$.get("/Messages/GetVendorMessageCount/", { vendorId: "@ViewBag.VendorId" })
.done(function (data) {
totalMessageCount = totalMessageCount + Number(data);
$(".MessageCount").html(data);
});
$.get("/Messages/GetVendorNotifyCount/", { vendorId: "@ViewBag.VendorId" })
.done(function (data) {
totalMessageCount = totalMessageCount + Number(data);
$(".NotifyCount").html(data);
});
$.get("/Messages/GetVendorTaskCount/", { vendorId: "@ViewBag.VendorId" })
.done(function (data) {
totalMessageCount = totalMessageCount + Number(data);
$(".TaskCount").html(data);
});
console.log("-" + totalMessageCount);
$(".TotalMessageCount").html(totalMessageCount);
My controller returns the correct int values for each .get and they are displaying correctly. The problem is totalMessageCount
is zero at the end. So for some reason, the totalMessageCount = totalMessageCount + Number(data)
line doesn't seem to be working. It's gotta be something stupid I'm doing, been a long day... thanks