how to send on users profile page on selecting username( using json autosuggest script)
Posted
by I Like PHP
on Stack Overflow
See other posts from Stack Overflow
or by I Like PHP
Published on 2010-04-21T13:00:31Z
Indexed on
2010/04/21
15:03 UTC
Read the original article
Hit count: 280
i m using auto suggest using Ajax Json .
now when a user select a user name , i want to send user on the link of that user name
my json data is coming in this way
{
query:'hel',
suggestions:["hello world","hell boy ","bac to hell"],
data:["2","26","34"]
}
now what i want that user goes to http://userProfile.php?uid=26
on select username(suppose user select "hell boy")
how to do this??
UPDATE: i describe what i m doing step by step i m using a searchbox using jquery ajax, when user write some text on input box , we show (suggest) value regarading their search
STEP 1. when user write atleast(2 letter) <input type="text" name="q" id="query" />
then a function(below) in invoked in which i send the value written on text box(eg. hell).
<script type="text/javascript" language="javascript">
var options, a;
jQuery(function(){
options = { serviceUrl:'rpc.php' };
var a = $('#query').autocomplete({
serviceUrl:'rpc.php',
minChars:3,
delimiter: /(,|;)\s*/, // regex or character
maxHeight:400,
width:300,
zIndex: 9999,
deferRequestBy: 0, //miliseconds
});
});
</script>
STEP 3: on rpc.php
, i collect the data and show using JSON
my final data come in below format
{
query:'hell',
suggestions:["hello world","hell boy ","bac to hell"],
data:["2","26","34"]
}
where suggestion list having username and data is userid( from user_tables). above data comes in a div (on frontend) where user name displayed in a list
STEP 4: now if i select any username using uparrow, downarrow then that name is filled in input box,
STEP 5: now what i want that when user select usename then page automatically goes to that user's profile section ( userprofile.php?uid=2
)
© Stack Overflow or respective owner