GetAll Getting Called Twice

Topics: jQuery
Feb 11, 2011 at 3:43 AM

Hi, I'm experimenting with this and so I wanted to exercise the GetAll function that is in the default WCFJQuery example. But, when I do a JQuery Get, I see that the GetAll method is called twice. Do you have any ideas as to why that might happen? Here is the JQuery code I inserted right after the post method already there:

 

	$.get("./Service/", null, function (result) {
                $.ajax({
                    url: "./Service/",
                    data: { returnResult: true },
                    cache: false,
                    success: function (result) {
                        for (i = 0; i <= result.length; i++) {
                            $("#Peoples").append("<li><b>Name:</b> " + i + " " + result[i].Name + "</li>");
                        }
                    }
                });
            });

Any help is appreciated!

Chris

Feb 11, 2011 at 2:25 PM
Hi Chris,

You are doing an $.ajax call once you get a result from the $.get, so you should only use either one or the other. Like:

$.get("./Service/", null, function (result) {
      for (i = 0; i <= result.length; i++) {
           $("#Peoples").append("<li><b>Name:</b> " + i + " " + result[i].Name + "</li>");
      }
});

Cheers,
Gus

Feb 11, 2011 at 5:19 PM

Ah, thanks Gus, I appreciate it. :)