I'm beginning to use jQuery + JSON in conjunction w/ my asp .net
applications and using Firebug to debug issues that I come across.
Below is what my web service looks like:

[WebMethod]
    public string JSONObject()
    {
        StringBuilder payload = new StringBuilder();

        using (JsonTextWriter writer = new JsonTextWriter(new
StringWriter(payload)))
        {
            writer.WriteStartObject();
            writer.WriteMember("CityName");
            writer.WriteString("San Diego");
            writer.WriteEndObject();
        }

        return payload.ToString();
    }

Below is how I'm calling the web service:

$("#btn").click(function(event)
            {
                $.ajax({
                    type: "POST",
                    url: "../Webservices/WebService.asmx/JSONObject",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg)
                    {
                        try
                        {
                            var obj = eval('(' + msg.d +
')');
                            alert
(obj.CityName);
                        }
                        catch(err)
                        {
                            alert(err);
                        }
                    },
                    error: function()
                    {
                        alert("error");
                    }
                  });

                event.preventDefault();
            });

And below is what Firebug reports as the response:

{"d":"{\"CityName\":\"San Diego\"}"}{"d":"{\"CityName\":\"San Diego
\"}"}{"d":"{\"CityName\":\"San Diego\"}"}

I would expect to see:

{"d":"{\"CityName\":\"San Diego\"}"}

as the response.  Am I seeing a bug or perhaps I'm doing something
wrong?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to