Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In your ashx, you need to get the data from reading the post data... </p> <pre><code> StringBuilder HttpInputStream; public void ProcessRequest(HttpContext context) { HttpInputStream = new StringBuilder(); GetInputStream(context); // the data will be in the HttpInputStream now // What you might want to do it to use convert it to a .Net class ie, // This is using Newtonsoft JSON // JsonConvert.DeserializeObject&lt;JsonMessageGet&gt;(HttpInputStream.ToString()); } private void GetInputStream(HttpContext context) { using (Stream st = context.Request.InputStream) { byte[] buf = new byte[context.Request.InputStream.Length]; int iRead = st.Read(buf, 0, buf.Length); HttpInputStream.Append(Encoding.UTF8.GetString(buf)); } } </code></pre> <p>In your response back the caller - your ashx needs to respond in JSON so the caller JavaScript can consume it. </p> <p>I suggest using Newstonsoft JSON eg...</p> <pre><code> public void ProcessRequest(HttpContext context) { // read from stream and process (above code) // output context.Response.ContentType = "application/json"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(JsonConvert.SerializeObject(objToSerialize, new IsoDateTimeConverter())); } </code></pre> <p>OR to make it really really easy, change to - basically needs to respond back in JSON for the JavaScript handler to process it</p> <pre><code> public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; context.Response.Write("{data:\"Reply message\"}"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload