1

I try to do pagination in server side with web service (.asmx), problem is response. Response comes xml format not json.

<?xml version="1.0" encoding="utf-8"?><string xmlns="http://tempuri.org/">{"Total":5,"Results":[{"id":5,"text":"a a a"},{"id":4,"text":"name yenice"},{"id":2,"text":"user user1"},{"id":1,"text":"user user2"},{"id":3,"text":"user3"}]}</string>

Js code here :

  $("#test").select2({
            minimumInputLength: 2,
            minimumResultsForSearch: 10,
            ajax: {
                url: URL,
                dataType: "json",
                type: "GET",
                data: function (params) {

                    var c = {
                        searchTerm: '', // search term
                        pageNum: 1,
                        pageSize: 10
                    }
                    return c;
                },
                processResults: function (data) {
                    return {
                        results: $.map(data, function (item) {
                            return {
                                text: item.tag_value,
                                id: item.tag_id
                            }
                        })
                    };
                }
            }
        });

1 Answer 1

1

Finally i solve problem in server side :

    [WebMethod(EnableSession = true)]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public void Sample(string searchTerm, int pageSize, int pageNum)
    {
        //var result.... 
        Context.Response.Write(JsonConvert.SerializeObject(result)); 
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.