| | |
Ajax Search as google?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2009
Posts: 19
Reputation:
Solved Threads: 0
Hi frnds....
i am trying to do search like google....
my files r here......but it displays nothing....i mean no output and no error...plz check the code what the error?
eg: in a text box type "a"
then "a" related words r displayed...
google.phpp
google.html
i am trying to do search like google....
my files r here......but it displays nothing....i mean no output and no error...plz check the code what the error?
eg: in a text box type "a"
then "a" related words r displayed...
google.phpp
<?php
$file=fopen("http://www.google.com/complete/search?h1=en&js=true&qu=" . $_GET["qu"],"r");
while(!feof($file)){
$d=fgets($file);
echo $d;
echo "no";
}
fclose($file);
?>google.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>google search</title>
<script language="javascript">
function getData(dataSource)
{
var XMLHttpRequestObject = false;
if(window.XMLHttpRequest){
XMLHttpRequestObject=new XMLHttpRequest();
}else if(window.ActiveXObject){
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}
if(XMLHttpRequestObject){
XMLHttpRequestObject.open("GET",dataSource);
XMLHttpRequestObject.onreadystatechange=function(){
if(XMLHttpRequestObject.readyState ==4 && XMLHttpRequestObject.status==200){
eval(XMLHttpRequestObject.responseText);}
}
XMLHttpRequestObject.send(null);
}
}
function connectGoogleSuggest(keyEvent){
var input=document.getElementById("textField");
if(input.value){
getData("google.php?qu=" +input.value);
}else{
var targetDiv=document.getElementById("targetDiv");
targetDiv.innerHTML= "<div></div>";
}
}
function sendRPCDone(unusedVariable,searchTerm,arrayTerm,arrayResults,unusedArray){
var data="<table>";
var loopIndex;
if(arrayResults.length !=0){
for(var loopIndex=0; loopIndex < arrayResults.length; loopIndex++){
data +="<tr><td>" + "<a href='http://www.google.com/search?q=" + arrayTerm[loopIndex] +"'>" +arrayTerm[loopIndex] +'</a></td><td>' + arrayResults[loopIndex] + "</td></tr>";
}
}
data +="</table>" ;
var targetDiv=document.getElementById("targetDiv");
targetDiv.innerHTML=data;
}
</script>
</head>
<body>
<input id="textField" type="text" name="textField" onkeyup="connectGoogleSuggest(event)" />
<div id="tagetDiv" ><div></div></div>
</body>
</html>![]() |
Similar Threads
- could i search images in a folder using php in offline (PHP)
- How to search data? (JavaScript / DHTML / AJAX)
- sample code for form validation using ajax (JavaScript / DHTML / AJAX)
- google ajax search api ( youtube videoBar) (JavaScript / DHTML / AJAX)
- Google API Search Engine Code (JavaScript / DHTML / AJAX)
- Filtered search function on a website (JavaScript / DHTML / AJAX)
- Image upload using Ajax (PHP)
- Levyo Ajax Gallery supports Firefox 2.0.1 only?? (IT Professionals' Lounge)
Other Threads in the PHP Forum
- Previous Thread: Result without while loop
- Next Thread: contact form
| Thread Tools | Search this Thread |
# 5.2.10 access action address apache api array auto autoincrement broken cakephp checkbox class classes clean clients cms code cron curl database date dehasher destroy directory dissertation domain dropdown dynamic echo$_get[x]changingitintovariable... email encode error errorlog fairness fatalerror file folder form function functions href htaccess html image include indentedsubcategory ip javascript joomla legislation limit link load local login mail masterthesis memberships menu methods multiple multipletables mysql mysqlquery newsletters oop open passwords paypal pdf persist php popup provider query radio random script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable voteup web youtube





