I have been creating an ajax search. I have been wondering how to load the user's profile when clicked on the search results using ajax. I tried assigning the ID of user from database to div using the following code so that I can have an ajax to load the profile:-
echo "<div id='$id'><img src='$img' /></div>
I wanted to set an ajax to load profile page and from the profile page, there will be a query to search database for the user. The variable ($img/$id) seems to work on the
img tag but did not work on
div id. So, I am stuck wondering how facebook and google+. I tried googling but, no such results were found.
To put it in simpler words, I don't know how to assign a variable (to id or any other place an ajax can get the value from) so that ajax can load it and then post it to the profile.php so that profile.php can query the database and show the results.
edit: Since some of you might misunderstand, I don't have a problem with assigning the image, I have problem assigning an id as a variable so that I can auto assign it using database .