Exact duplicate of http://stackoverflow.com/questions/2302382
Ive set up a basic client side callback to a WCF service. see sample code below.
when viewing using an http filter attached to the explorer you can see that: 1. service1.svc/js is working fine and return proper java script to the browser 2. serrvice1.svc works and returns a proper json data. 3. call is fine and using alert instead of updating the div info i get the data.
but then after OK on the alert the page is then reloaded from scratch.
cant understand why? got any idea?
code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Simple_ClientNetwork_Calls.WebForm1" %>
<!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 runat="server">
<title></title>
</head>
<body >
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/WebKit.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="~/Service1.svc" />
</Services>
</asp:ScriptManager>
<script type="text/javascript">
var BedList = null;
var status = null;
//add a window.load handler to init any necessary controls
Sys.Application.add_load(initializeControls);
function initializeControls(e) {
status = $get("status");
}
function testme() {
document.bgColor = "#FF0000";
getBedList();
}
function getBedList() {
iMDsoft.Demo.SimpleService.GetBedList(GetBedListOnSuccess, GetBedListOnFailed);
}
function GetBedListOnSuccess(results, context, methodName) {
var BedList = results
status.innerText = "Complete" + BedList[0].Name;
}
function GetBedListOnFailed(results, context, methodName) {
status.innerText = "GetBedListOnFailed: " + results.get_message();
}
</script>
<button id="button1" onclick="testme();" >TestMe</button>
<div id="status">
</div>
</div>
</form>
</body>
</html>