I am really new to this jquery stuff. I have a wcf web service running:
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
[WebInvoke(Method="GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle=WebMessageBodyStyle.Wrapped)]
string SayHello();
}
public class HelloWorlService : IHelloWorldService
{
public string SayHello()
{
return "Hello ";
}
}
When I enter http: // localhost: 62604 / HelloWorld.svc / SayHello in google chrome, I get the following result: {"SayHelloResult": "Hello"}
So it looks like it is working.
Now I create default.html that looks like this:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function CallService() {
$.ajax({
url: "http://localhost:62604/HelloWorld.svc/SayHello",
type: "GET",
dataType: "json",
processdata = false,
contentType: "application/json; charset=utf-8",
sucess:function(data) { alert('success'); },
error: function (e) { alert('failed'); }
});
}
$(document).ready(function () {
$("a").click(function () {
CallService();
});
});
</script>
</head>
<body>
<a href="">Link</a>
</body>
</html>
So, very simple stuff ... but it doesn't work ... I always get a warning about a failed message .... I lost a little here, not sure what is wrong.
Any help is appreciated.
EDIT: the default.html page is not hosted on a web server, it is just a simple file that I open in a browser. Could this be the reason that it is not working properly?