Я хочу вызвать просмотр, используя вызов AJAX с ASP.net MVC2.0, но он не работает нормально.Это метод AJAX
$.ajax({
type: 'POST',
url: '../Inventoryhealth/IHView?mac=' + val + '&name=' + val2 + '#fragment-3',
//url: '../Chart/CreateChart2?chartType=Column&a=null',
success: function (result) {
var res = result;
if (res != null && res == "1")
alert('System information can\'t be retrieved');
}
});
, но если я его использую, он отлично работает
location.href = "../Inventoryhealth/IHView?mac=" + val + "&name=" + val2 + "#fragment-3";
Это код вида
public ActionResult IHView(String mac, string name)
{
try
{
ViewData["PollTime"] = new ClientConfigurationService().getPollTime() * 60000;
SystemInventoryService sis = new SystemInventoryService();
SystemInformation systemInfo = new SystemInformation();
systemInfo = sis.getSystemInventory(mac);
systemInfo.ChartRefreshInterval = getInterval();
systemInfo.OName = name;
bool MoreCores = true;
if (Convert.ToInt16(systemInfo.NumberOfCores) < 2)
{
systemInfo.Core1UsageDetail = "0";
systemInfo.Core2UsageDetail = "0";
MoreCores = false;
}
Add(systemInfo.ProcessorLoadPercentage, systemInfo.MemoryTotalVirtualMemorySize, systemInfo.MemoryFreeVirtualMemory, systemInfo.DrivesSize, systemInfo.DrivesTotalFreeSpace, MoreCores, systemInfo.Core1UsageDetail, systemInfo.Core2UsageDetail);
var AC = new ActiveClient();
AC.ClientMac = mac;
if (db.ActiveClients.Count() > 0)
{
db.DeleteObject(db.ActiveClients.First());
}
db.AddToActiveClients(AC);
db.SaveChanges();
if (systemInfo != null)
{
return View(systemInfo);
}
else
{
// If Healh and status can't be retrieved
// Response.Redirect("../Inventoryhealth/InventoryIndex?error=1");
return Content("1");
}
}
Есть идеи?