Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 553521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:36:50+00:00 2026-05-13T11:36:50+00:00

There’s a great tutorial on IBM’s website which walked me through a simple search/results

  • 0

There’s a great tutorial on IBM’s website which walked me through a simple search/results list using jQuery,PHP and Ajax.

I was able to make it work and it’s really cool.

One problem. I want the results to be hyperlinks and I can’t get any java script to run on the results.

Here is the script I have (includes what was in the tutorial plus the additional script necessary to ovverride the hyperlink, click behavior):

<script type='text/javascript'>
$(document).ready(function(){
$("#search_results").slideUp();
$("#search_button").click(function(e){
e.preventDefault();
ajax_search();
});
$("#search_term").keyup(function(e){
e.preventDefault();
ajax_search();
});
$("a").click(ClickInterceptor);
});

function ajax_search(){
$("#search_results").show();
var search_val=$("#search_term").val();
$.post("./find.php", {search_term : search_val}, function(data){
if (data.length>0){
$("#search_results").html(data);
}
})
}

function ClickInterceptor(e)
{
window.alert("Hellow World!");
return false;
}
</script> 

If i put the following html under the <body> tag:

<a href="test">this will work</a>

That will display the alert window.

However, if I change the results to hyperlinks (found in find.php, listing 7 from the tutorial):

$string .= "<a href=\"test\">".$row->name."</a> - "; 

It does not work.

Any idea on how to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:36:50+00:00Added an answer on May 13, 2026 at 11:36 am

    The click function binds when it is run. You need to change it to a live binding.

    $("a").live("click", ClickInterceptor);
    

    Or you can just bind it when you update the search results by putting the following after $("#search_results").html(data):

    $("#search_results a").click(ClickInterceptor);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are few apps like Strava which records users movements using GPS. It also
There is a known issue with using jquery fadeOut, fadeIn, and fadeToggle, when fading
There are many algorithms for finding optimal binary search trees given a set of
There have been several questions on SO regarding getting Contacts numbers using the Contacts
There are several shading languages available today like GLSL, HLSL, CG, which one to
There's a bug in FireBug: I accidentally clicked where the line numbers are, which
There is a website called Gild.com that has different coding puzzles/challenges for users to
There is a div (form) which opens on the click of a button. There
There is no doubt that MonoTouch is one of the great cross-compiler(s). Similarly, SenchaTouch
There are a lot of Jquery plugins and libraries. and sometimes I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.