ASP.NET( WCF ) (ASHX) JSON . JSON ( - ), - , json , javascript.
, , , , JSON , javascript .
:
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/json";
context.Response.WriteFile("~/myData.json");
}
public bool IsReusable {
get {
return false;
}
}
}
:
myData =
(function ()
{
var json = null;
$.ajax({
'async': false,
'global': false,
'url': "handler.ashx",
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
}
)();
alert(myData.MyArray[0].MyProperty);