开发者

Jquery AutoComplete Load Problem

Not Work

Jquery Code:

$('[id$=Name]').autocomplete('CallBack.aspx',{formatItem: function(item){return item.Name;}}).re开发者_JAVA技巧sult(function(event, item) {
            location.href = item.AGE;
        });

Json:

var data = [{NAME:"John",AGE:"57"}];

Work

Jquery Code:

var data = [{NAME:"John",AGE:"57"}];

 $('[id$=Name]').autocomplete(data,{formatItem: function(item){return item.Name;}}).result(function(event, item) {
                location.href = item.AGE;
            });

alt text http://img11.imageshack.us/img11/119/38235621.jpg

Help me pls how its make ? callback.aspx return json not work


Try changing your data to this:

var data = [{id:"John",value:"57"}];

EDIT

Here's a sample of what I think you're trying to do:

var data = [{NAME:"John",AGE:"57"}];

$('[id$=Name]').autocomplete('CallBack.aspx', {
    formatItem: function(item) {
        return item.NAME;
    }}).result(function(event, item) {
            location.href = 'somepage.aspx?age=' + item.AGE;
        });

Basically you needed to capitalise return item.Name to return item.NAME.


Try This

<script type="text/javascript">
    $(document).ready(function () {

        $("#TextboxId").autocomplete({

            source: function (request, response) {
                $.ajax({
                    url: "URL",
                    type: "POST",
                    dataType: "json",
                    data: { ids: idstopass },

                    success: function (retrieveddata) {

                        alert(retrieveddata);
                        var dData = JSON.parse(retrieveddata);
                        alert(dData.Name);

                    },
                    error: function (request, status, error) {
                        console.log("Error! " + request.responseText);

                    }
                })
            },


        });
    })
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜