Problem AJAX(ing) JSON object on Mac Firefox version (3.6.12)

后端 未结 2 1145
长发绾君心
长发绾君心 2021-01-19 12:41

Let\'s say I want to call some server method and pass it the following JSON object:

var t = { \"test\": 0};

I\'m using jQuery library $.aja

相关标签:
2条回答
  • 2021-01-19 13:22

    I've end up modifying GetInputStream() method to replace "%Pr" with closing bracket using regex:

     public string GetInputStream()
     {
        string inputContent;
        using (var sr = new System.IO.StreamReader(Request.InputStream))
           inputContent = sr.ReadToEnd();
    
        inputContent = System.Text.RegularExpressions.Regex.Replace(inputContent, "%Pr$", "}");
    
        return Server.UrlDecode(inputContent.Split('=')[1]);
    }
    

    I know it's not solving cause of the problem but at least I'm buying some time to come up with solution :-(

    0 讨论(0)
  • 2021-01-19 13:25

    I think this is a duplicate of JQuery AJAX Error in Firefox on Mac with "Managed" Users

    The problem is a conflict between Firefox and the parental controls in Mac OS X 10.5. The last two characters of the POST data are replaced with Pr. The problem was first reported two years ago, and it doesn't look like it will be fixed.

    The best work around I am aware of is to use SSL because that seems to prevent the problem. If that isn't an option, then you need to add at least 2 characters to the end of your POST data which can be ignored. In a form that would mean adding something like <input type="hidden" name "useless" value="useless"> to the end of the form (credit to Miquel Botanch). For JSON/XML requests, the last few characters are important for parsing. If you can't just add spaces or new lines (maybe that would work, I haven't tried), then you need to add some other dummy value client side. Finally, server side you'd need to detect and remove this extra dummy value (as krul's answer does).

    0 讨论(0)
提交回复
热议问题