0

In an asp.net mvc 4 web application I have a kendo grid (named ExternalUserList) where I have added a custom column with checkboxes in order to send an email to selected users. What I do is send the database id of the user(s) in json format to my mvc controller.

This is my javascript code:

<script type="text/javascript">
    function sendMailToExternalUsers() {
        var ids = [];
        var proId;
        var checkBox = $('#ExternalUsersList > table > tbody > tr td:nth-child(2) > input');

        checkBox.each(function (index) {
            var $input = $(this);

            if ($input.is(':checked')) {
                var count = index + 1;
                proId = $('#ExternalUsersList > table > tbody > tr:nth-child(' + count + ') td:first-child');
                ids.push(proId[0].innerText);
            }
        })

        var postData = JSON.stringify(ids);

        $.ajax({
            type: "POST",
            url: "/ExternalUser/SendEmailToExternalUsers/",
            data: postData,
            dataType: "json",
            contentType: "application/json",
            traditional: true
        });
    }
</script>

and here is my controller:

[HttpPost]
public EmptyResult SendEmailToExternalUsers(List<string> ids)
{
   //Here i do some processing
}

All the above code works fine in Internet Explorer and Chrome but on Firefox it does not. In fact if i have selected for example 3 users from the kendo grid, visual studio debugger shows that ids List<string> has 3 elements but values are empty. In IE and Chrome values are perfectly correct.

So is wrong with it?

AndreyAkinshin
  • 18,603
  • 29
  • 96
  • 155
Giorgos Manoltzas
  • 1,710
  • 5
  • 24
  • 34

1 Answers1

0

It's most probably something related to your client-side code. I'd guess it is this line

ids.push(proId[0].innerText);

Try to debug that with Firebug to see what gets returned. You might also want to use the jQuery's methods .text() or .html() depending on what you're interested in.

Juri
  • 32,424
  • 20
  • 102
  • 136
  • You are right the problem is in this line of code. prodId[0].innerText and prodId[0].text() are both undefined. prodId[0].html() raises an exception. – Giorgos Manoltzas Mar 29 '13 at 08:17
  • @VimalStan I am sorry but i cannot accept the answer as it is not the solution to the problem. It is only a suggestion. – Giorgos Manoltzas Apr 02 '13 at 08:47
  • @GiorgosManoltzas The "solution" is to rely on the .text() or .html() functions of jQuery which work cross-browser. See this SO question for clarifications: http://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-not-in-firefox – Juri Apr 02 '13 at 09:12