2012-02-16 91 views
0

我試圖通過自定義值自動完成,因此:自動完成DOS不顯示結果傳遞自定義值

我自定義的工作價值的公司總部設在this question

使用類似的文檔的默認來源:

$("#inpPesqCli").autocomplete({ 
     source: "ajax/search.php", 
     minLength: 2, 
     autoFocus: true 
    }); 

螢火返回此(例如):

[... 
    { "id": "29083", "label": "SOME ONE 2", "value": "SOMEONE WITH LELE" }, 

    { "id": "19905", "label": "SOME ONE", "value": "SOMEONE WITH LALA"}, 
...] 

作品的完美,結果顯示出來。


當我嘗試設置一些自定義的值:

$("#inpPesqCli").autocomplete({ 
    source: function(request, response) { 
     $.ajax({ 
      url: "ajax/search.php", 
      dataType: "jsonp", 
      data: { 
       featureClass: "P", 
       style: "full", 
       maxRows: 12, 
       name_startsWith: request.term 
      }, 
      success: function(data) { 
       response($.map(data.geonames, function(item) { 
        return { 
         label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, 
         value: item.name 
        } 
       })); 
      } 
     }); 
    }, 
    minLength: 2, 
    autoFocus: true 
}); 

Firebug的回報就是我完全相同的數組結果:

[... 
    { "id": "29083", "label": "SOME ONE 2", "value": "SOMEONE WITH LELE" }, 

    { "id": "19905", "label": "SOME ONE", "value": "SOMEONE WITH LALA"}, 
    ...] 

,但問題是,當我通過定製calues ,結果的劑量出現。

PHP:

$type = "C"; 
$q = strtolower($_GET["name_startsWith"]); // this i change: custom = name_startsWith/default = term 

if (!$q) return; 

$res = $p->SomeClass($codemp,$q,$type); 

$items = array(); 
while(!$res->EOF){ 
    $items[$res->fields["NOMCLI"]] = $res->fields["CODCLI"]; 
    $res->MoveNext(); 
} 
    // below this, i have the php autocomplete default function, if u need, ask then i post. 

不知道我錯過了什麼。

回答

0

一套AJAX類型= GET,也許工作,默認情況下發送數據類型是POST

$("#inpPesqCli").autocomplete({ 
    source: function(request, response) { 
     $.ajax({ 
      url: "ajax/search.php", 
      dataType: "jsonp", 
      type : "GET", 
      data: { 
       featureClass: "P", 
       style: "full", 
       maxRows: 12, 
       name_startsWith: request.term 
      }, 
      success: function(data) { 
       response($.map(data.geonames, function(item) { 
        return { 
         label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, 
         value: item.name 
        } 
       })); 
      } 
     }); 
    }, 
    minLength: 2, 
    autoFocus: true 
}); 
+0

AREADY嘗試,同樣的問題。 – 2012-02-16 12:59:07