I have a function in c# that gets a budget and Id-s of ads and updates all the budgets of these ads to be with budget value of budget
:
[HttpPost]
public ActionResult UpdateAdsBudgets(string budget, string[] Ids)
{
ServerResult serverResult = null;
try
{
int numOfSuccess = 0;
for (int i = 0; i < Ids.Length; i++)
{
serverResult = UpdateAdBudget(Ids[i]);
if (serverResult.ServerResultState == ServerResultState.SUCCESS)
{
numOfSuccess++;
}
}
}
}
I called this function in my js
file:
$.ajax({
dataType: 'json',
type: "POST",
traditional: true,
url: "/AdsController/UpdateAdsBudgets",
data: { budget: budget, Ids: adsIds },
success: function (serverResult) {
},
error: function (exception) {
}
});
Is there an option to display a message with an info of the called function? I mean to: 2/5 ads were updated
, where 2 is numOfSuccess
(the variable of my c# file) and 5 is: adsIds.length
.
I know I can do a lot of ajax calling (for each ad) and then count it in the succes, but is there an option that the function of c# will update online a variable in my js file? (assuming the variable: "numberOfSuccededAds").
any help appreciated!