Get Classic ASP variable from posted JSON

后端 未结 8 1975
挽巷
挽巷 2021-02-08 11:01

I\'m trying to post JSON via AJAX to a Classic ASP page, which retrieves the value, checks a database and returns JSON to the original page.

I can post JSON via AJAX. I

8条回答
  •  爱一瞬间的悲伤
    2021-02-08 11:14

    Generally (new VBArray(arr).toArray()) should work on a SafeArray, which is what Request.BinaryRead returns. But it doesn't. I found this solution which I revised:

    function GetRawRequestData() {
        var byteCount = Request.TotalBytes;
        var binary = Request.BinaryRead(byteCount)
        var reader = Server.CreateObject('ADODB.Recordset');
        reader.Fields.Append('x', 201, byteCount);
        reader.Open();
        reader.AddNew();
        reader.Fields(0).AppendChunk(binary);
        reader.update();
        return reader.Fields(0).Value;
    }
    

    thanks to Rasberry's comment @ http://blogs.msdn.com/b/david.wang/archive/2006/07/04/howto-convert-between-jscript-array-and-vb-safe-array.aspx

    Note that it might not handle encoding correctly. I didn't dive into what 201 for ADO datatype means, but it works.

提交回复
热议问题