====== Dealer Locator Ajax Sample Code ====== ===== Overview ===== Add a Dealer Locator search to your existing public website by embedding including a little javascript to do an ajax call. In the ajax approach, you use a form similar to the one from the iframe approach, but use javascript to intercept the form submit and do an ajax request back to the channelsuite server. The returned html table is inserted into a
in your code and rendered by your browser without redrawing the whole page. ===== Steps ===== 1. Set up a DealerLocator.css file. Here's a [[DealerLocator.css | good place to start]]. Unlike the iframe approach where the html styles are supplied by the channelsuite server, the html returned by the ajax approach uses styles specified on your site, giving you a lot more control over the appearance of your dealer locator results. 2. Include the necessary javascript and CSS files in your html section. You'll need to know the base URL of your channelsuite install, probably something like //yourcompany.channelsuite.com// 3. Set up a form in your html to allow your website visitors to enter some search parameters. See the main [[dealer_locator]] page for info on the supported search parameters. The form element id parameters must match the search parameter names, and the onSubmit parameter must be specified as shown. In the following example we allow search by country. Please see the [[api_helper_functions]] section for an explanation of the available country codes.
Please select your country:

4. Place a div with id="output-div" somewhere in your html page; the html code returned by the ajax call will replace the contents of output-div. Also, optionally place an empty iframe to catch normally submitted search results when javascript is not available, add the iframe id as a target= in the form tag.
Results go Here!
5. Edit the DealerLocator.css file to match the rest of your site that should do it!