Jump to content
xt:Commerce Community Forum

Ajax Suche mit Dropdown Problem


rezeptionist

Recommended Posts

Hallo Community,

ich komme einfach nicht weiter und hoffe Ihr könnt mir helfen.

Es geht um eine Ajax Suche mit Dropdown

Hier mein bisheriger Code:

ajax.php

<?php

if (isset($_GET['id']) && $_GET['id'] != 'all' ) {
$herst_id = (int)$_REQUEST['id'];
$json = array();
//Verbindung zur Datenbank herstellen...
$query = "select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = " . $herst_id;
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
array_push($json, array(
'oV' => $row['manufacturers_id'],
'oT' => $row['manufacturers_name']
));
}
echo json_encode($json);
}

?>[/php]

script.js

[code]$(function() { $('#hersteller').change(function(){ $.ajax({ url: ('ajax.php'), data: 'id=' + $(this).val(), type: 'GET', timeout: 2000, dataType: 'json', error: function() { alert('Error loading json data!'); }, success: function(json){ var output = ''; for (p in json) { output += '<option value=\"' + json[p].oV + '\">' + json[p].oT + '</option>\n'; } $('#typ').html(output); } }) }); });[/code]

neuesuchbox.html

[html]{literal}
<script type="text/javascript" src="script.js"></script>
{/literal}

<label for="hersteller">Hersteller</label>
<select name="hersteller" id="hersteller">
<option value="all">- alle -</option>
<option value="1">Herrsteller 1</option>
<option value="2">Herrsteller 2</option>
<option value="3">Herrsteller 3</option>
</select>

<label for="typ">Typ</label>
<select name="typ" id="typ">
<option value="all">- alle -</option>
</select>[/html]

Das ganze soll mehr oder weniger für eine spezielle suche genutzt werden.

Den Produkten wurden noch zusätzliche Infos mitgegeben die durch diese suche gefiltert werden sollen.

Mein Problem ist nun das ich keine [b]Daten aus der DB erhalte[/b] egal was ich bisher angestellt habe es kam nichts an .

Vielleicht stehe ich ja auch nur auf dem Schlauch !

EDIT:

Fehlermeldungen gibt es nur die eine

"Error loading json data"

Bitte um Hilfe.

greets

Link to comment
Share on other sites

Archived

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

×
  • Create New...