Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery UI自动完成jsonp映射响应_Javascript_Jquery_Ajax_Jquery Ui_Jsonp - Fatal编程技术网

Javascript jQuery UI自动完成jsonp映射响应

Javascript jQuery UI自动完成jsonp映射响应,javascript,jquery,ajax,jquery-ui,jsonp,Javascript,Jquery,Ajax,Jquery Ui,Jsonp,我正在尝试使用来自jqueryUI的自动完成。当我向响应发出警报时,我得到以下信息:([{“id”:“test”,“label”:“test”,“value”:“test”}) 但当我尝试映射结果时,下拉结果为空。这是我的密码: <script> $(function() { function log( message ) { $( "<div/>" ).text( message ).prependTo( "#log" ); $(

我正在尝试使用来自jqueryUI的自动完成。当我向响应发出警报时,我得到以下信息:
([{“id”:“test”,“label”:“test”,“value”:“test”})

但当我尝试映射结果时,下拉结果为空。这是我的密码:

<script>
$(function() {
    function log( message ) {
        $( "<div/>" ).text( message ).prependTo( "#log" );
        $( "#log" ).scrollTop( 0 );
    }

    $( "#city" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "http://localhost/jQuery/development-bundle/demos/autocomplete/search3.php",
                jsonp: "jsonp_callback",
                data: {
                    featureClass: "P",
                    style: "full",
                    maxRows: 12,
                    name_startsWith: request.term
                },
                success: function( data ) {
                    alert(data);
                    response( $.map( data, function( item ) {
                        return {
                            label: item.label,
                            value: item.value
                        }
                    }));
                }
            });
        },
        minLength: 2,
        select: function( event, ui ) {
            log( ui.item ?
                "Selected: " + ui.item.label :
                "Nothing selected, input was " + this.value);
        },
        open: function() {
            $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
        },
        close: function() {
            $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
        }
    });
});
</script>
无论如何谢谢你使用这句话

url: "http://ws.geonames.org/searchJSON?jsonp_callback=?",
以及数据类型

dataType: 'jsonp',
而不是

url: "http://ws.geonames.org/searchJSON",

我的错误复制了错误的代码我使用了这个url找到了我的脚本获取数据并使用echo$\u get['jsonp\u callback'](“.$data”);我使用此url我已将url更改为:?现在是我的回答:?([{“id”:“Jimmy”,“label”:“Jimmy”,“value”:“Jimmy”});但下拉列表仍然是空的
url: "http://ws.geonames.org/searchJSON",