According to the calling logic between All view and ActionsHeaderE view , you call the
All action firstly and the session value is null at this time . And then use ajax to call the ActionsHeaderE action to set the session value. The return data of the success function in ajax is only the data list from database,
not contain the session and call the All action again.
If you want to get number of records from ajax , you could refer to below:
success: function (data) {
var a = Object.keys(data).length;
$('a[href^="#home"]').html(a + " Actions");
$("#ActionsEtags").empty();
$.each(data, function (index, item) {
console.log(item);
$('<tr id="Row' + index + '">' +
'<td>' + item.Id + '</td>' +
'<td>' + item.Name + '</td>' +
'</tr>').appendTo($('#ActionsEtags'));
});
}
Best Regards,
Sherry
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
62 Points
180 Posts
Value passed by session from method to another does not work!
May 14, 2020 08:27 AM|musbah7@hotmail.com|LINK
Hi
I have tow query type models that I want to get their data by ajax in one view with Entity Framework Core.
I'm trying to pass the number of records returned by Ajax to the caller view by session, But no value returned.
All view which I tried to return number of records returned by Ajax (@ViewBag.A):
But when I pressed Search button the records are returned successfully but with blank space of number of records Why? and How to solve please?
Contributor
2070 Points
606 Posts
Re: Value passed by session from method to another does not work!
May 14, 2020 10:26 AM|Sherry Chen|LINK
Hi musbah7@hotmail.com ,
According to the calling logic between All view and ActionsHeaderE view , you call the All action firstly and the session value is null at this time . And then use ajax to call the ActionsHeaderE action to set the session value. The return data of the success function in ajax is only the data list from database, not contain the session and call the All action again.
If you want to get number of records from ajax , you could refer to below:
Best Regards,
Sherry
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
62 Points
180 Posts
Re: Value passed by session from method to another does not work!
May 14, 2020 11:02 AM|musbah7@hotmail.com|LINK
Thanks