Register FAQ Search Today's Posts Mark Forums Read
Miva Merchant Community Forums
User Name
Password
dreamingdigital
  #1  
Old Posted: 11-15-07, 08:55 PM
Mivite
dreamingdigital's Avatar
Joined Aug 2006
Posts: 447 dreamingdigital is on a distinguished road
Anybody Do an MM5 Ajax Search Yet?
Ever been to Apple's "new" site. Notice their Search? It's awesome. Do you guys think that would be possible in MM5? I do. Has anybody tried yet? Even a proof of concept?

Colin Puttick
I solemnly swear that I am up to no good...
 
Reply With Quote
tbogus
  #2  
Old Posted: 11-16-07, 02:47 PM
Mivite
Joined Mar 2006
Posts: 376 tbogus is on a distinguished road
Re: Anybody Do an MM5 Ajax Search Yet?
it looks like their search is based off of internal keywords for each search - that's the best I've seen on the net - mimics their internal spotlight functionality...

Not sure if it'd practical for an ecommerce environment - unless you wanted to incorporate your upsold products into it...

Tim.

Tim Bogus
 
Reply With Quote
dreamingdigital
  #3  
Old Posted: 12-29-07, 10:48 AM
Mivite
dreamingdigital's Avatar
Joined Aug 2006
Posts: 447 dreamingdigital is on a distinguished road
Re: Anybody Do an MM5 Ajax Search Yet?
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

Colin Puttick
I solemnly swear that I am up to no good...
 
Reply With Quote
quipdigital
  #4  
Old Posted: 01-17-08, 12:43 PM
Mini Mivite
Joined Jun 2006
Posts: 88 quipdigital is on a distinguished road
Re: Anybody Do an MM5 Ajax Search Yet?
Ooh. I checked out the site and that search is pretty sexy. I've been thinking about doing something similar with our site. I think you may have inspired me.

Thanks,

Dustin
 
Reply With Quote
dreamingdigital
  #5  
Old Posted: 01-31-08, 11:55 AM
Mivite
dreamingdigital's Avatar
Joined Aug 2006
Posts: 447 dreamingdigital is on a distinguished road
Re: Anybody Do an MM5 Ajax Search Yet?
It is cool. MM5 search is a lot slower than a PHP serch is but it's not so slow that it's hard to use. Fast typers and quick enter button clickers might never see the integrated search results though. Oh well.

Colin Puttick
I solemnly swear that I am up to no good...
 
Reply With Quote

Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 02:19 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.