I forgot to say that I pulled it off a month ago. It's really cool. I can't post a link but if you PM me I'll give you a huge obvious clue.
Here's what I did:
Got the basic AJAX code from
http://www.w3schools.com/ajax/ajax_intro.asp
I had to write a function to not call the search until the user typed in at least 3 characters. And since Miva is a lot slower than just pure PHP I had to build in a tiny delay.
Here is the javascript code I made that is part custom and mostly stock from W3schools.
Code:
function ajax_search_me() {
var search_term = document.getElementById("search_term").value;
var method = "GET";
var url = "/Merchant2/merchant.mvc?Screen=SRCH&Ajax=true&srch_name=1&srch_code=1&Search=" + escape(search_term);
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById("ajax_search_holder").style.visibility = "visible";
document.getElementById("ajax_search_holder").innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open(method,url,true);
xmlHttp.send(null);
}
function do_nothing() {
return;
}
var alertTimerId = 0;
alertTimerId = setTimeout("do_nothing()", 1);
function search_delay() {
var search_term = document.getElementById("search_term").value;
if (search_term.length > 2) {
alertTimerId = setTimeout("ajax_search_me()", 150);
}
else {
clearTimeout(alertTimerId);
document.getElementById("ajax_search_holder").style.visibility = "hidden";
}
If you study the above code you can see I'm using the power search module from emporium plus and just searching the product code and name.
In my SRCH page I put the entire thing in an if/else statement and if my variable I'm passing Ajax=true is there it displays one search results layout and if not it displays the normal SRCH page. What's cool is that the Ajax search even works on the search page (cool because you're on that page and it's calling that page).
But, that's as much code as I'm posting. You can easily figure out the Miva code for the SRCH page yourself.
I'm a super noob at Ajax so I'm scheming more ways to use it in a MM5 environment.
CP