0
$.ajax({
    async: false,
    url: '@Url.Action("UpdateMS")' + "?MAC=" + $('#MAC').val() + "&Serial=" + $('#Serial').val() + "&I_ID=" + $('#I_ID').val(),
    dataType: "json",
    cache: false,
    success: function (data) {
        $("#Serial_Number").val("");
        $("#MAC_Address").val("");
        $("#Message").text(data);
        alert(data[0]);
        if (data[0] == 'D') {                        
            $("#PartOne").css("display", "inline");
            $("#PartTwo").css("display", "none");
            $("#MACSerial").val("");
            $("#MACSerial").focus();
        }
    }
});

data is a JSON string having the value Device Updated.

Here is the issue:

On Google Chrome and the like works like a charm.

data[0] has a value of "D" (Ie. the first character in a string array).

Except on a stinky old mobile device it reports value undefined when i run my test alert!

data itself produces the proper string "Device Updated" correctly on all browsers.

Any ideas?? Thanks!

Kuf
  • 17,318
  • 6
  • 67
  • 91
Pinch
  • 4,009
  • 8
  • 40
  • 60

1 Answers1

3

Try using data.charAt(0). Your way of accessing a string is not supported by all browsers.

Check this JavaScript access string chars as array out, there's explanation as to why in the answers.

Community
  • 1
  • 1
Sreenath S
  • 1,269
  • 1
  • 14
  • 21
  • 1
    Also, if your MAC, Serial, and I_ID are all part of the same form, you can use the jQuery .serialize() function and the data property of jQuery .ajax() to send the information in a much more readable format. – LJ2 Aug 21 '12 at 13:58
  • Thanks alot for your help! Now i can have my morning Oats! – Pinch Aug 21 '12 at 14:00