<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server" >
<script type = "text/javascript" src = "">
function click()
{
new Ajax.Request('Handler.ashx',
{
method: 'get',
onSucess: function transport() {
var response = transport.responseText();
var Obj = response.evalJSON(true);
for (i = 0; i < 6; i++) {
MyDiv.innerHTML = Obj.IM(i);
}
},
onFailure: function() { alert("There is something went wrong"); }
});
}
</script>
<title></title>
</head >
<body>
<form id="form1" runat="server">
<input id="Button1" type="button" value="button" onclick=" click()" />
<div id = "MyDiv">
</div>
</form>
</body>
</html>
This is my handler
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using System.Text;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
string[] Img = new string[5] { "http://farm4.static.flickr.com/3210/3033577103_f80cb2e399_t.jpg", "http://farm1.static.flickr.com/76/184936863_dceeaa048c_t.jpg", "http://farm4.static.flickr.com/3133/2630880079_9035711f2f_t.jpg", "http://farm4.static.flickr.com/3064/2395929114_a4d69a22c6_t.jpg", "http://farm3.static.flickr.com/2195/2214604053_1de19931cf_t.jpg" };
int[] Name = new int[5]{1,2,3,4,5};
StringBuilder output = new StringBuilder();
output.Append("{Images:[");
for (int i = 0; i < 5; i++)
{
output.Append("{");
output.Append("\"Nam\":\""+Name[i].ToString() +"\",");
output.Append("\"IM\":\"" +Img[i] + "\" ");
if (i != 4)
{
output.Append("},");
}
}
output.Append("}");
output.Append("]}");
context.Response.Write(output);
}
public bool IsReusable {
get {
return false;
}
}
}
WHY IT DSNT show anything else...i suppose to get JSON string but