开发者

JQuery AJAX Error in Firefox on Mac with "Managed" Users

I'm having a problem with a JQuery AJAX call in Firefox (3.6.13 thru 4.x) on the Mac (OS-10.5). The problem only occurs when the user is "Managed for Parental Controls." It does not happen for "Standard" or "Administrator" users, and it does not happen in Safari or Chrome for any users. This problem does not occur anywhere in a Windows environment.

I have a simple ASP.NET page (ASPX) that calls a simple ASP.NET Web Service (ASMX). The error message that is returned is:

Exception Type: System.ArgumentException Message: Invalid object passed in, ':' or '}' expected. (23): { 'data' : 'something'Pr Stack Trace: at System.Web.Script. Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth) at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input) at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)

This error is happening during JSON deserialization and is not actually making it to the service method. Note that the letters "Pr" are inserted in the JSON object that's being passed and the trailing curly bracket is omitted (thus causing the error): " { 'data' : 'something'Pr". The letters "Pr" do not appear in the Post when I examine it in Firebug.

This looks like a bug in Firefox to me. Any thoughts?

Here's code:

WEB SERVICE:

using System;
using System.Web;
using System.Web.Services;

namespace TestWebApp
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class MacAjaxTestService : System.Web.Services.WebService
    {
        [WebMethod]
        public string TestServiceCall(string data)
        {
            return "Data Received = '" + data + "'.";
        }
    }
}

ASPX PAGE:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MacAjaxTest.aspx.cs" Inherits="TestWebApp.MacAjaxTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>MAC AJAX TEST</title>
    <script language="javascript" type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.min.js"></script>
    <script type="text/javascript" language="javascript">

        $(function ()
        {
            $("#TestButton").button().click(TestButton_Click);
            $("#TestText").focus();
            $("#ResultsDiv").text("").css({ "border": "solid 1px #999999", "width": "600px", "min-height": "100px" });
        });

        function TestButton_Click()
        {
            $("#ResultsDiv").text("");
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "MacAjaxTestService.asmx/TestServiceCall",
                data: "{ 'data' : '" + $("#TestText").val() + "' }",
                dataType: "json",
                success: function (data)
                {
                    $("#ResultsDiv").text(data.d);
                },
                error: function (jqXHR, textStatus, errorThrown)
                {
                    //be sure customErrors mode="Off" in web.config.
                    var error = $.parseJSON(jqXHR.responseText);
                    var msg = "Exception Type: " + error.ExceptionType + "<br />"
                        + "Message: " + error.Message + "<br />";

                    if (error.StackTrace != null && error.StackTrace.length > 0)
                        msg += "Stack Trace: " + error.StackTrace;

                    $("#ResultsDiv").html(msg);
                }
            });
     开发者_运维技巧   }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2>MAC AJAX TEST</h2>
        <br />
        <input type="text" id="TestText" />
        <input type="button" id="TestButton" value="Test" />
        <br /><br /><br />
        Results:
        <br />
        <div id="ResultsDiv"></div>
    </div>
    </form>
</body>
</html>


Looks like this is a long-existing bug in Firefox / MacOS

https://bugzilla.mozilla.org/show_bug.cgi?id=489575

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜