我收到带有汉字的 Ajax 错误,任何人都可以分享修复吗?
错误
jQuery
var jqxhr = $.post("Handler1.ashx", function () {
alert("success");
}).fail(function (data) {
alert("error");
});
C#
public void ProcessRequest(HttpContext context)
{
var ticketResponse = new TicketResponse();
ticketResponse.AddedCount = 23;
// All tickets were available and were added to the cart
ticketResponse.Success = true;
ticketResponse.SuccessItems = new List<SuccessfullItem>
{
new SuccessfullItem()
{
OrderItemId = 1,
Title = "【桃姐與我】舞台劇(粵語)粵語)"
}
};
var output = Serializer.Serialize(ticketResponse);
context.Response.AddHeader("Content-Type", "application/json");
context.Response.AddHeader("Content-Length", output.Length.ToString());
context.Response.AddHeader("Content-Disposition", "inline");
context.Response.AddHeader("Content-Transfer-Encoding", "text");
context.Response.Write(output);
context.Response.Flush();
context.ApplicationInstance.CompleteRequest();
}