0

我在通过 AJAX 调用多个函数时遇到问题。我主要要做的是通过AJAX调用不同的函数。这应该是这样工作的,当我尝试调用这些函数时,它们应该被发送一个请求,并且响应应该是这些函数的返回值,但是这样做时我得到了错误。谁能建议我如何使它工作?

public virtual IQueryable<CardViewModel> ChannelQuery(PageInfo p)
    {
        var q = from client in my.Clients(0, 0)
                join m in db.Channels on client.ClientId equals m.ClientId
                join c in db.Contents on m.ChannelId equals c.ContentId
                where c.ContentName.Contains(p.Where) ||                  m.ChannelShortDescription.Contains(p.Where) || m.ChannelName.Contains(p.Where)
                select new CardViewModel
                {
                    Name = "Channel",
                    ID = m.ChannelId,
                    Title = m.ChannelName,
                    Description = m.ChannelShortDescription,
                    Pic = new VZDev.ViewModels.Pic { width = 255, height = 170, source = `enter code here`m.ChannelLogo, text = m.ChannelName },
                    PictureViewTemplate = "_PicBanner",
                    ShowTools = true
                };
        return q;
    }
    public virtual IQueryable<CardViewModel> ContentsQueries(PageInfo p)
    {
        var query = from content in db.Contents
                    join clients in my.Clients(0, 0) on content.ClientId equals clients.ClientId
                    join m in db.Channels on clients.ClientId equals m.ClientId
                    where content.ContentName.Contains(p.Where) || `enter code here`m.ChannelShortDescription.Contains(p.Where) || m.ChannelName.Contains(p.Where)
                    select new CardViewModel
                    {
                        Name = "Content",
                        ID = content.ContentId,
                        Title = content.ContentName,
                        Description = clients.ResellerName,
                        Pic = new VZDev.ViewModels.Pic { width = 255, height = 170, source = `enter code here`"None", text = content.ContentName },
                        PictureViewTemplate = "_PicBanner",
                        ShowTools = true
                    };
        return query;

    }

    public ViewResult Advance(PageInfo p)
    {
        return View(ChannelQuery(p).ToPagedResult(p, "ID Desc"));
    }
4

1 回答 1

0

每个 AJAX 调用只能调用一个函数。如果您在一个请求中需要 Channel 和 Content 数据,请创建一个字典来保存两组值。像这样的东西:

Dictionary<string,object> data = new Dictionary<string,object>();
data.Add("Channel", ChannelQuery());
data.Add("Content", ContentsQuery());
于 2013-11-12T13:34:46.010 回答