Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
This is the WCF Service code:

C#
[OperationContract]
        [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        public String GreetJson()
        {
            Greeting g = new Greeting();
            g.Message = "Hello World!";
            Console.WriteLine("call received");
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return serializer.Serialize(g); ;
        }


and the client request:
PHP
$("#test").click(function(){
$.getJSON("http://192.168.10.183:8001/GreetJson",function(data)
            {
                alert("test=" + data);
            });
});
...
<img src="data/images/menu/highscore.png" alt="Highscore" id="test" />


if we use http://192.168.10.183:8001/GreetJson in a browser we get:
"{\"Message\":\"Hello World!\"}"

Our problem is that we don't receive any response from the server when we do getJSON request.

Console.WriteLine("call received"); //the message appears in the console but on the browser there is no alert box.
Any idea why?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900