-1

Nothing happaned when i try do this in release mode but in debug mode all work fine - why???

When i adding button and outputing data by clicking this buton.My inner links in my list rows work fine also ( http://clip2net.com/s/2AG04 ).And only on $(document).ready(function () { event this doesn't want to work...

On client i have:

$(document).ready(function () {
    $.ajax({
        url: '@Url.Action("Index", "Product")',
        cache: false,
        type: 'GET',
        dataType: 'json',
        proccessData: false,
        contentType: 'application/json; charset=utf-8'
    });

On server i have this:

public ActionResult Index()
    {
        if (Request.IsAjaxRequest())
        {
            //Отправляем на клиент данные 
            _senderHub.SendMessage();
            return null;
        }
        return View();
    }

Also on server:(SignalR)

readonly ManagerDB _managerDB = new ManagerDB();
    public void SendMessage()
    {
        IEnumerable<ProductModels> list = _managerDB.GetListOfProduct1();
        var listToClient = new List<ProductModels>();
        foreach (var prod in list)
        {
            listToClient.Add(new ProductModels
                                 {
                                     Id = prod.Id,
                                     Name = prod.Name,
                                     LockType = prod.LockType,
                                     LockTime = prod.LockTime,
                                     LockUser = prod.LockUser,
                                     TimeStampF = prod.TimeStampF
                                 });
        }
        var anonimProduct = listToClient;
        IHubContext context = GlobalHost.ConnectionManager.GetHubContext<SenderHub>();
        context.Clients.AddListRows(anonimProduct);
    }

On client(SignalR) trying catch this data:

$(function () {
    var senderHub = $.connection.senderHub;
    senderHub.AddListRows = function (data) {
        var dataFromServer = data;
        var listOfData = "";
        for (var i = 0; i < dataFromServer.length; i++) {
            $("#ListOfProductsTableBody").html(null);
            var userId = '';
            if (dataFromServer[i].LockUser != null) {
                userId = dataFromServer[i].LockUser;
            }
            listOfData += ("<tr><td>" + dataFromServer[i].Id + "</td><td>" + dataFromServer[i].Name + "</td><td>" + userId + "</td><td>" + dataFromServer[i].LockType + "</td>" + "<td id=\"ModifyBlock\"><a id=\"Detail\" href=\"#\" alt=" + dataFromServer[i].Id + " >Детально</a>|<a id=\"Delete\" href=\"#\" alt=" + dataFromServer[i].Id + " >Удалить</a>|<a id=\"Edit\" href=\"#\" class=\"" + dataFromServer[i].LockTime + "\" alt=" + dataFromServer[i].Id + " >Редактировать</a></td></td></tr>");
        }
        $("#ListOfProductsTableBody").append(listOfData);
    };
    $.connection.hub.start();
});

emphasized text

GameScripting
  • 16,092
  • 13
  • 59
  • 98
Dimarik
  • 41
  • 5

1 Answers1

1

See David Fowler's response to my question. Looks like you have the same issue.

Server to client messages not going through with SignalR in ASP.NET MVC 4

Community
  • 1
  • 1
Pete
  • 6,585
  • 5
  • 43
  • 69