Hello i am quite new to jQuery. I am trying to insert search results in to page without reloading it, but unsuccessful. Here is the code i am using:

$(document).ready(function(){
  $("a").click(function(event){
	  $.get( 
		 "search.php",
		 { query: "intel" },
		 function(data) {
			$('#content').html(data);
		 }
	  );
  });
});

i am using example form some page. I edited it but i lack the knowledge to make it work.

you need to add event.preventDefault(); to your onclick function to prevent your page from being redirected by the link you are clicking on
leaving out the href from the tag or having an empty href just tells the page to redirect to its self

$("a").click(function(event){
	  event.preventDefault();
	  $.get( 
		 "search.php",
		 { query: "intel" },
		 function(data) {
			$('#content').html(data);
		 }
	  );
  });

I agree with jstfsklh211, but event.preventDefault() has always crashed my javascript in IE.
So if you're worried about IE, I would do this:

$("a").click(function(event){
	  if(!$.browser.msie) { // if you're not in IE, do this
event.preventDefault();
}
	  $.get( 
		 "search.php",
		 { query: "intel" },
		 function(data) {
			$('#content').html(data);
		 }
	  );
  });

<a onclick="function(); return false;">...</a>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.