I make a Json call to an ashx handler like this:
attributes = $("#pageHtmlTag").attr("class").trim();
urlToHandler = 'JSonTestHandler.ashx';
jsonData = '{' + attributes + '}';
$.ajax({
url: urlToHandler,
data: jsonData,
dataType: 'json',
type: 'POST',
contentType: 'application/json',
success: function (data) {
setAutocompleteData(data.responseDateTime);
$("body").add("<div>" + data.toString() + " </div>").appendTo(document.body);
alert("grate suceees");
},
error: function (data, status, jqXHR) {
alert('There was an error.' + jqXHR);
}
}); // end $.ajax
I receieve it and proccess it. I also want to send back some HTML to be displayed but i dont know how to send html back to the Jscript.
ashx:
string jsonData = new StreamReader(context.Request.InputStream, System.Text.Encoding.UTF8).ReadToEnd();
.............................
var testResultReportString = testResultReport.GetReportHtml();
var serializer = new JavaScriptSerializer();
var jSonTestResultReport = serializer.Serialize(testResultReportString);
context.Response.Write(jSonTestResultReport);
So the question is. How do i return data to the Ajax calls success function?