-3

我第一次尝试使用 jquery ajax 自动完成扩展器,到目前为止它对我来说并不奏效。请指出错误和建议以使这项工作。

    <script type="text/javascript">

$(document).ready(function()
{
                $.support.cors=true;
        $('#firstName').autocomplete({

                alert('HEY');
                minLength:2,
                source: function( request, response) {
                $.ajax({
                    type: 'GET',
                    url: 'http://MyServer/MyService/api/StaffSearch/GetStaffByFirstName'
                    data: {'term': request.term},
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(data) {
                        alert('success in autocomplete');
                        response(data);
                    },
                    error: function(msg) {
                        alert('error in autocomplete');
                    }
                })
        },

        })//end autocomplete

});
    </script>


    <div>
        <label for="firstName">First Name</label>
        <input type="text" id="firstName" name="firstName">
    </div>
4

1 回答 1

1

你错过$.ajax({

于 2013-03-19T17:54:20.543 回答