$.ajax proxy

$.ajax proxy

hi

I am using $.ajax to invoke page methods, I am using the following code in javascript:


        $().ready(function() {

            $('#<%=cbCustomGroups.ClientID%>').change(function() {

                var customgroupParam = Object();
                customgroupParam.customGroupCode = $(this).val();
                var customgroupParam =
JSON.stringify(customgroupParam);

                $.ajax({
                    type: "POST",
                    url: "InsercionRecompra.aspx/
GetCustomGroupsMinimunYears",
                    data: customgroupParam,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: false,
                    success: function(result) {

                        var ddlMonth = $('#<%=ddlMonth.ClientID %>');
                        var ddlMonthTo = $('#<%=ddlMonthTo.ClientID
%>');

                        $(">option", ddlMonth).remove();
                        $(">option", ddlMonthTo).remove();

                        $.each(result.d, function() {

                            ddlMonth.append($('<option></
option>').val(this.Id).html(this.Description));
                            ddlMonthTo.append($('<option></
option>').val(this.Id).html(this.Description));

                        });

                        $(">option:last", ddlMonthTo).attr('selected',
'selected');

                    },
                    error: function(XMLHttpRequest, textStatus,
errorThrown) {
                        HandleError(XMLHttpRequest, textStatus,
errorThrown);
                    }
                });

            });

        });

In the page, InsercionRecompra.aspx, I have the method:

        [WebMethod, ScriptMethod]
        public static List<KeyValueItem>
GetCustomGroupsMinimunYears(string customGroupCode)
        {

            List<CustomGroupMinimum> CustomGroupMinimum =
CustomGroupMinimumService.GetByCustomGroupCode(customGroupCode);

            List<int> query = (from item in CustomGroupMinimum
                               select item.YearMonth).ToList<int>();

            return
GenericFunctions.ConvertMonthsKrafPeriodFormatted(query);;

        }

       
the returned class

    public class KeyValueItem
    {
        public string Id { get; set; }
        public string Description { get; set; }
    }
   

I am using the upper code, but it has much code, and it is used in all application

exist some proxy, o technique to reduce the web method invocation ?


greetings