Click here to Skip to main content
11,706,979 members (60,096 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Javascript WCF jQuery , +
This is the WCF Service code:

[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:
$("#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 8-Apr-12 4:15am

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 165
1 OriginalGriff 125
2 chainerlt 110
3 ppolymorphe 89
4 Mika Wendelius 70
0 OriginalGriff 9,178
1 Sergey Alexandrovich Kryukov 8,512
2 CPallini 5,189
3 Maciej Los 4,766
4 Mika Wendelius 3,696


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 8 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100