jQuery autocomplete with jsonp

Ads
 

jQuery autocomplete with jsonp

Im trying to develope an autocomplete script using jQuery, now Im in the last step. I need to make a php page to call database, but the problem is I dont know how the data(to be called to autocomplete)should lok like. I know the script using something call "jsonp"

Here is the important lines that i want to show you, and my question is: How to build php code to make corectly data for this ?

function e(){f=-1;$("#ac_results").css("display",
"none")}function g(l,m){$.trim(p.val().toLowerCase())===l.toLowerCase()&&$.ajax({dataType:"jsonp",url:ac_server+"/"+encodeURIComponent(l)+"?callback=?&t="+m,success:function(k){var r=parseInt(k.t);
if(r>=s){s=r;t[l]=k.r;++w;b(k.r,l)}}})}var f=-1,h=0,n=i,s=0,t=[],w=0,p;return{bind:function(){p=$(a);if(typeof ac_server==="undefined")return c();p.attr("autocomplete","off");
p.bind("keyup",function(l){var m=(new Date).getTime(),k=$.trim($(this).val());
k=k.toLowerCase();if(!(l.keyCode in[40,38,13,27]||!n))if(k.length>
0)t[k]!==undefined?b(t[k],k):setTimeout(function(){g(k,m)},0);else e()});$(document).bind("keyup",function(l){if(l.keyCode===27)e();else if(l.keyCode!=undefined){$(".ac_active").attr("class","ac_inactive");switch(l.keyCode){case 40:if(f==-1)f=0;else if(++f>=h)f=0;$("#ac_opt_"+f).attr("class","ac_active");d($("#ac_opt_"+f));break;case 38:if(f==-1)f=h-1;else if(--f<0)f=h-1;$("#ac_opt_"+f).attr("class","ac_active");d($("#ac_opt_"+f));break;case 13:if(f!=-1){l=$("#ac_opt_"+f);l.length&&d(l,1)}else e()}}});
$("body").bind("click.autocompleter",function(){$(this).attr("id").indexOf("ac_")===-1&&e()});return this},fa:c}}("#ac_q");
(function(a){a.fn.U=function(b){var c=this;b=a.extend({A:"tactive",p:"tnactive",aa:".toptions",B:0,z:"href"},b||{});a(this).each(function(){var d=a(this).find(b.aa).children(),e;d.each(function(g){a(this).addClass(b.p);a(this).click(function(f){f.preventDefault();a(this).addClass(b.p);f=c.find(a(this).attr(b.z));if(f.length===0)throw"Could not find matching tab content for id: "+a(this).attr(b.z);e.removeClass(b.A).addClass(b.p);a(e.attr(b.z)).hide();a(this).removeClass(b.p).addClass(b.A);f.show();
e=a(this)});
if(g===b.B||g===0&&d.length-1<b.B){e=a(this);
a(this).trigger("click")}})})}})(jQuery);

thanks for further help

View Answers

June 21, 2011 at 8:43 PM

More explaination: I really dont know what is the variable i should make and what it should be look like. but here is something I tried but still not work.

//db connection detils
$host = "localhost";

$user = "root"; $password = "yourpasswordhere"; $database = "comments";

//make connection

$server = mysql_connect($host, $user, $password); $connection = mysqlselectdb($database, $server);

//query the database

$query = mysql_query("SELECT * FROM comments");

//loop through and return results

for ($x = 0, $numrows = mysqlnumrows($query); $x < $numrows; $x++) { $row = mysqlfetchassoc($query);

    $comments[$x] = array("name" => $row["name"], "comment" => $row["comment"]);        
}

//echo JSON to page
$response = $_GET["jsoncallback"] . "(" . json_encode($comments) . ")";
echo $response;

June 22, 2011 at 10:53 AM


June 22, 2011 at 11:28 AM

Hi, thanks, its not what Im looking for. This script that I post is a perfect script. Can be used like perfectly search engine like google.

I have got it from a web site, but what I have to do is finding the php code to give the correctly data.

Its hard work i know, but i i found it, will be perfect.


June 22, 2011 at 11:46 AM

I mean if i found it, will be perfect, hehe but i not found it yet.

Ads









Related Tutorials/Questions & Answers:
jQuery autocomplete with jsonp
jQuery autocomplete with jsonp  Im trying to develope an autocomplete script using jQuery, now Im in the last step. I need to make a php page... to autocomplete)should lok like. I know the script using something call "jsonp
jQuery UI Widget : Autocomplete
jQuery UI Widget : Autocomplete       Query UI Widget : Autocomplete Using autocomplete widget , you can add autocomplete feature to your input 
Advertisements
jQuery Autocomplete fetch_object fatal error?
jQuery Autocomplete fetch_object fatal error?  I am consistently... of Jquery Autocomplete box. <script> $(function() { var... the database information etc. http://www.roseindia.net/tutorial/ajax/jquery
is it possible to add a button inside an autocomplete jquery ui plugin?
is it possible to add a button inside an autocomplete jquery ui plugin?  is it possible to add a button inside an autocomplete jquery ui plugin? My requirement: I have a 4 text input fields that I want to implement autocomplete
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Sir, Lots of thnx to ur reply .I went through both the tutorials... autocomplete textbox using jquery in jsp from mysql database. Kindly send me
Selecting value from autocomplete textbox using jquery in jsp
Selecting value from autocomplete textbox using jquery in jsp   hello Sir, I completed ur tutorial on autocompletion textbox from database using Jquery in jsp .It worked Fine .Thank you For Ur valuable Guidance .But it does
Selecting a radio button in jquery autocomplete from database value
Selecting a radio button in jquery autocomplete from database value  I can get the data from the database using PDO to my jquery.js file. How do I... radio button? Here is the pertinent code: $("#name").autocomplete
autocomplete
autocomplete  I used autocomplete from roseindida.net.. i am getting the autocomplete is coming the retrieved values of database in the list..but when i select the value it is not displaying on the field.. and again i need
JQuery
, use jquery autocomplete
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
autocomplete(): Spring mvc with jquery: I am not getting correct value...;jQuery UI Autocomplete - Multiple, remote</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
ModuleNotFoundError: No module named 'jsonp'
ModuleNotFoundError: No module named 'jsonp'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'jsonp' How to remove the ModuleNotFoundError: No module named 'jsonp'
JQuery
using url of the doctors, use jquery autocomplete
JQuery
JQuery  how to use jquery
Jquery
Jquery  I am new to Jquery. Can anyone please tell me how to use jquery plugins in html
jquery
jquery  What are the Jquery similarities or difference with other java script libraries
Version of com.earldouglas>jsonp-filter dependency
List of Version of com.earldouglas>jsonp-filter dependency
JQuery
JQuery  How i begin JQuery and where i begin learning?   Please visit the following link: JQuery Tutorials Learn Jquery from the above link. Here you will get lot of examples with illustration
ModuleNotFoundError: No module named 'django_jsonp'
ModuleNotFoundError: No module named 'django_jsonp'  Hi, My Python... 'django_jsonp' How to remove the ModuleNotFoundError: No module named 'django_jsonp' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django_jsonp'
ModuleNotFoundError: No module named 'django_jsonp'  Hi, My Python... 'django_jsonp' How to remove the ModuleNotFoundError: No module named 'django_jsonp' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangorestframework-jsonp'
ModuleNotFoundError: No module named 'djangorestframework-jsonp'  Hi...: No module named 'djangorestframework-jsonp' How to remove the ModuleNotFoundError: No module named 'djangorestframework-jsonp' error? Thanks  
jQuery
jQuery  Hi, What is jQuery and how it is used to develop Web applications? Thanks
jquery
jquery  how to display the leaves taken or holidays of the year or half working days in a calendar in some colors to identify the days using jquery plugin
JQuery
JQuery  how to create jquery auto-complete textbox ? in which data come from database table?   Please visit the following link: http://www.roseindia.net/tutorial/jquery/autoSuggestTextbox.html   thank you
jQuery - jQuery Tutorials and examples
jquery UI Widgets a)Accordion b)Autocomplete c)Button d... jQuery - jQuery Tutorials and examples       The largest collection of jQuery examples
Maven Dependency jsonp-filter >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.earldouglas >> jsonp-filter version1.0.0 in your project
Maven Dependency jsonp-filter >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of com.earldouglas >> jsonp-filter version1.1.0 in your project
Maven Dependency jsonp-filter >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of com.earldouglas >> jsonp-filter version1.1.1 in your project
Autocomplete demo not working
Autocomplete demo not working  Hi Team, I am so happy with our examples on Autocomplete , http://www.roseindia.net/tutorial/jquery/autoComplete.html I have copied the source files to my local machine and renamed
Autocomplete demo
Autocomplete demo   Thanks for the autocomplete demo, it's working fine but results are showing in different fashion Please see attached image. Can some one help me
Autocomplete demo
Autocomplete demo   Thanks for the autocomplete demo, it's working fine but results are showing in different fashion Please see attached image. Can some one help me

Ads