Jump to content

Search Results using URL


mcmuney

Recommended Posts

<input type="text" style="width:290px; border:  solid 1px #b1b1b1; height: 17px;" id="searchtags" name="searchtags" value="" />
<input type="image" src="images/search.jpg" onclick="searchImages()"/></div>

 

searchImages() function is called inside a .js file:

 

function searchImagesResponse(originalRequest)
{
   var response = originalRequest.responseText;
   var divResponse = $('divResponse');
   divResponse.innerHTML = response;
   var loading = $('loading');
   loading.style.display = 'none';
}

 

PROBLEM: I can't use the string on the url to directly show the results. For example: site.com/index.php?searchtags=tag_here. What can I do so that I can use the url to show search results?

Link to comment
https://forums.phpfreaks.com/topic/152495-search-results-using-url/
Share on other sites

This looks like an ajax problem..

 

I'm not sure what you're asking.  You want to use an ajax method of searching AND go to the url ?  or you just want the users to be able to see the search url, for instance if they want to bookmark it?

 

Both can be done using your javascript function to create and display the appropriate link ... but it seems counterproductive unless I misunderstand.

Well... all it is is the same keywords searched..

 

Didn't you say yourself it was something like: site.com/index.php?searchtags=tag_here  ?

If so, your search function searchImages() must build url to query somewhere.. so take that query and copy/paste/mail/do whatever with it so that you get what you want..  you know what I mean?

I found the code, but I'm not sure what to change to show the URL. I want to point out that if I manually enter the path now (site.com/index.php?searchtags=tag_here), it does not show any results:

 

function searchImages()
{
var loading = $('loading');
loading.style.display = 'block';
var searchtags = document.getElementById('searchtags').value;
var ip = 0;
var url = 'ajax/search.php';
var pars = 'searchtags=' + encodeURIComponent(searchtags);


var myAjax = new Ajax.Request(
	url, 
	{
		method: 'get', 
		parameters: pars, 
		onComplete: searchImagesResponse
	});
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.