开发者

I need solution for jquery ajax autocomplete in php

开发者 https://www.devze.com 2023-01-26 16:30 出处:网络
I have used jquery for javascript in my project I need to create autocomplete with php ajax I am using below code

I have used jquery for javascript in my project I need to create autocomplete with php ajax

I am using below code

$("input#txtaddkey").autocomplete({
   source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
  });

And I have taken some code as below

$("input#txtaddkey").autocomplete({
   url: 'keyword.php',
     width: 300,
     max: 10,
     delay: 100,
     cacheLength: 1,
     scroll: false,
     highlight: false
  });

But I am not understand 开发者_StackOverflow社区how above code will work and How to get the query string from php file.

Please guide me.


Why don't you see at the Autocomplete page.

Basically your server response (the result in the keyword.php need to be formatted as JSON. i.e.

[ { "id": 1, "label": "text 1", "value": "val 1" }, { "id": 2, "label": "text2", "value": "val 2" } ]

Check also json_encode


I got the answer..

Query string will pass as $_GET['term'].

A request object, with a single property called "term", which refers to the value currently in the text input. For example, when the user entered "new yo" in a city field, the Autocomplete term will equal "new yo".

Thanks every one.

http://docs.jquery.com/UI/Autocomplete

0

精彩评论

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