asp.net jquery ajax json: Simple example of exchanging data

后端 未结 2 622
失恋的感觉
失恋的感觉 2021-01-13 13:16

(Question resolved with the help of the two reply posts--see below)

I would appreciate help getting a simple example of exchanging data JSON data between a browser (

2条回答
  •  孤街浪徒
    2021-01-13 13:28

    Other resource suggest removing the contentType: 'application/json; charset=utf-8', from the AJAX call:

      $.ajax({ 
                url: "ericHandler.ashx", 
                data: myData, 
                dataType: 'json', 
                type: 'POST', 
                success: function (data) { alert("DIDit = " + data.eric); }, 
                error: function (data, status, jqXHR) { alert("FAILED:" + status); } 
            }); 
    

    Read the values on the server side:

    string myPar = context.Request.Form["par"]; 
    

    You can also try:

    string json = new StreamReader(context.Request.InputStream).ReadToEnd(); 
    

    which was mentioned here: https://stackoverflow.com/a/8714375/139917

提交回复
热议问题