How to read data sent to classic ASP using jQuery AJAX

I wrote the following Javascript code:

function sendCcbRequest(text) {
    var jsonToSend = "\"text\": \"" + escape(text) + "\"";
    $.ajax({
        type: "POST",
        url: 'x.asp',
        data: jsonToSend,
        success: function(response) {
            alert("success:" + response);
        },
        error: function() {
            alert("error");
        }
    }); // end ajax
}

How to read the data that I send from my classic ASP code?

Update I tried the following for my classic asp x.asp file.

<%
Dim x
x = Request.Form("text")
Response.Write(x)
%>

He doesn't print anything.

+5
source share
4 answers

( ) . , Request.BinaryRead, , . , key1 = value1 & key2 = value2 {key1: 'value1', key2: 'value2'}, ASP Request.Form, .

+4

, -, . :

var jsonToSend = "\"text\": \"" + escape(text) + "\"";

var jsonToSend = { text: escape(text) };
+3

I would use the parser described here: Any good libraries for parsing JSON in classic ASP? . It worked for me.

0
source

On the page, x.aspsimply use: Request.Form("text")to read the text that sent your Ajax request.

0
source

All Articles