Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions jQuery autocomplete with jsonp

Have Programming Question? Ask it here!
 
 
 


Aleksander
jQuery autocomplete with jsonp
4 Answer(s)      3 years and a month ago
Posted in : JavaScript Questions


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


Advertisement
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.



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
jQuery Autocomplete : Autocomplete is a common feature available in lot of web... of jquery. This example shows A function for making autocomplete text box with the help of jquery plugin and php/mysql . In this example when we press the name
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.  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
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
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
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" />
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
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
JQuery
, use jquery autocomplete
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
JQuery
using url of the doctors, use jquery autocomplete
CAPXOUS AutoComplete
CAPXOUS AutoComplete       CAPXOUS AutoComplete is an AJAX suggestion component. You may have already tasted this impressive feature on web sites like Google GMail or in business
autocomplete displaying multiple fields
autocomplete displaying multiple fields  How can I create an autocomplete with three field (name, id, phone). Placing the phone field in the appropriate input field but selecting the name field into the 'calling' input box
JQuery
JQuery  how to use jquery
jquery
jquery  What are the Jquery similarities or difference with other java script libraries
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
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  hi there, I am just beginner for jQuery and i want to know-what is jQuery ? How it is better than JavaScript ?   jQuery... JavaScript : Each jQuery returns itself so you can chain them together(Chaining
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
Autocomplete textbox with database in jsp and follow the MVC model
Autocomplete textbox with database in jsp and follow the MVC model  i have one problem in my project i try to generate the autocomplete textbox...... Thanks in advance  Here is a jsp code that shows autocomplete box
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
CAPXOUS AutoComplete
CAPXOUS AutoComplete       CAPXOUS AutoComplete is an AJAX suggestion component. You may have already tasted this impressive feature on web sites like Google GMail or in business
JQuery-Disabling element in JQuery.
JQuery-Disabling element in JQuery.   How can we enable/disable an element in JQuery
jQuery Demos
jQuery autocomplete jQuery Button... jQuery Demos and quick examples       jQuery Demos The best way to learn a new technology
dhtmlxCombo - Ajax Autocomplete Combobox
dhtmlxCombo - Ajax Autocomplete Combobox   ... combo box with Ajax support. It is easy to configure. It also have autocomplete.... Filtering mode 6. Autocomplete mode 7. Editable mode   Four modes:  
use of jquery
use of jquery  what is a jquery? what is the evalution of jquery?   Hello Friend, Please visit the following link: JQuery Tutorials Thanks
learn jquery
learn jquery   is it possible to learn myself jquery,ajax and json   Yes, you can learn these technologies by yourself. Go through the following links: Ajax Tutorials JSON Tutorials JQuery Tutorials
learn jquery
learn jquery   is it possible to learn myself jquery,ajax and json   Yes, you can learn these technologies by yourself. Go through the following links: Ajax Tutorials JSON Tutorials JQuery Tutorials
Use of jQuery
Use of jQuery  What is the use of jQuery?   Hi, jQuery is JavaScript Ajax library. Developer is using it to create rich internet applications. Read at jQuery Tutorial. Thanks
PHP and JQuery
PHP and JQuery  How to make validation using PHP and JQuery
jQuery Tutorials, jQuery Tutorial
jQuery Tutorials, jQuery Tutorial The jQuery tutorials listed here will help you in learning jQuery easily. We have given many articles and easy to understand examples to making learning path easier. These jQuery tutorials
Introduction to jQuery UI plug-in
Introduction to jQuery UI plug-in       Introduction to jQuery UI plug-in JQuery UI stands for jQuery user interface. JQuery UI is a widget
PHP and JQuery
PHP and JQuery  How i validate input fields' data entry using JQuery
dynamic jquery statement
dynamic jquery statement  dynamic jquery statement
jQuery selectors
jQuery selectors       jQuery selectors In this tutorial we are discussing jQuery selectors. The jQuery selectors are one of the main feature in jQuery library
JQuery Spinner
JQuery Spinner   I am working in JQuery and i want to create SPinner for getting Credit Card Expiry Date in the form of MM/yyyy . Will you Please help me How to create the Spinner . Thank you. Regards Arun
Ajax in jQuery
Ajax in jQuery  How ajax can be use in JQuery?   Given below the code for ajax in jquery: $(document).ready(function() { $('#form').submit(function(){ var number = $('#number').val(); $.ajax({type:"post",url
parser jquery css
parser jquery css  How to parser jquery in css
jquery session handling
jquery session handling  What is session handling in JQuery
jQuery Training
jQuery Training     jQuery Training for learn jQuery fast The jQuery training is designed to teach jQuery in 5 days. After taking our jQuery training you will be able to start
Conflict with jQuery scripts
Conflict with jQuery scripts  Hi, How to avoid Conflict with jQuery scripts while using jQuery with other libraries? Thanks   Hi, Read the using jQuery with other libraries tutorial for more information. Thanks
JQuery-What is Connect?
JQuery-What is Connect?   What is Connect in JQuery and how can i use
Advertisements
 

 

 

DMCA.com