Datasheet

Chapter 1: AJAX Technologies
23
var credentials = document.getElementById(“credentials”);
credentials.style.display=”none”;
var employeeinfotable = document.getElementById(“employeeinfo”);
employeeinfotable.style.display=”block”;
var response = request.responseText;
eval(“var employee = ” + response + “;”);
var firstnamespan = document.getElementById(“firstname”);
firstnamespan.innerText = employee.firstname;
var lastnamespan = document.getElementById(“lastname”);
lastnamespan.innerText = employee.lastname;
var employeeidspan = document.getElementById(“employeeid”);
employeeidspan.innerText = employee.employeeid;
var departmentnamespan = document.getElementById(“departmentname”);
departmentnamespan.innerText = employee.departmentname;
}
}
window.credentials = function window$credentials(username, password)
{
// Same as Listing 2
}
function serialize(credentials)
{
// Same as Listing 2
}
function submitCallback()
{
// Same as Listing 2
}
</script>
</head>
<body>
<form id=”form1” runat=”server”>
// Same as Listing 2
</form>
</body>
</html>
In this listing, the Page_Load method generates a string that contains the JSON representation of the
employee object. This method writes the JSON representation into the response output stream and ends
the response as usual:
string json=”{\”firstname\”: \”Shahram\”,”;
json += “\”lastname\”: \”Khosravi\”,”;
json += “\”employeeid\”: 22223333,”;
json += “\”departmentname\”: \”Some Department\”}”;
Response.Write(json);
Response.End();
c01.indd 23c01.indd 23 8/20/07 5:40:12 PM8/20/07 5:40:12 PM