【发布时间】:2011-06-26 12:48:28
【问题描述】:
我遇到了无法解决的问题。部分原因是我无法用正确的术语来解释它。我是新手,很抱歉这个笨拙的问题。
您可以在下面看到我的目标的概述。我想从数据库(使用 ajax)中搜索一些东西并将结果显示在搜索下方的 div 中。这我可以让它工作。但是现在,我希望能够单击结果并将其放在页面顶部的 div 中。 我了解到 ajax 无法处理此类操作是正常的,并且无法将 jquery 或其他 ajax 调用运行到 ajax 调用中。 我还阅读了有关 jquery live() 的内容以解决此问题。
我仍然不清楚如何让事情发挥作用。
是否有可能让我走上正轨?有没有我错过的教程?
谢谢!
第一步
<div id="top">here comes an image</div>
<textfield> for the ajax search string + a button </textfield>
<div id="search">target of the ajax-search</div>
第二步:搜索后我们得到这个
<div id="top">here comes an image</div>
<textfield> for the ajax search string + a button </textfield>
<div id="search">result 01 with link to a php-file: a
result 02 with link to a php-file: b ... </div>
步骤树:点击结果 01 或 02 ...
<div id="top">content of php-file: a</div>
<textfield> for the ajax search string + a button </textfield>
<div id="search">result 01 with link to a php-file: a
result 02 with link to a php-file: b ... </div>
好的,这里是(相关)代码的一部分
search_page.php
<div id=top"></div>
<div class="client_search_field">
<form id="ui_element" class="sb_wrapper" action="" method="post" name="search_ID" ONSubmit="xmlhttpPost('search_stream_client_v02.php', 'ui_element', 'txtHint', '<img src=\'images/wait.gif\'>'); return false;">
<p> <span class="sb_down"></span>
<input name="search_string" type="text" class="sb_input" id="search_string" value="<?php echo $_POST['search_string']; ?>"/>
<button type="submit" class="submitmag" id="search_submit" > </button>
</p>
</div>
<span id="txtHint"></span>
search_stream_client_v02.php
<?php
$sql .= "SELECT *";
$sql .= ", MATCH(description, keywords) AGAINST ('".$_POST['search_string']."') AS score FROM archief WHERE MATCH(description, keywords) AGAINST('".$_POST['search_string']."' IN BOOLEAN MODE)";
$sql .= " AND showa = '1' ";
$sql .= $q_sort." ".$q_order." LIMIT 0,".$q_num_result;
$result04 = mysql_query($sql) or die(mysql_error());
while ($row04 = mysql_fetch_assoc($result04)){
$hint .= "<div class=\"tb-kader\">";
$hint .= "<span id=\"".$row['thumbnail']."\">";
$hint .= "<a href=\"".$row04['link']."\" class=\"fra tooltip lazy\" id=\"".$row04['ID']."\" TITLE=\"header=[".$row04['headline']."] body=[".$row04['description']."]\">";
$hint .= "<img src=\"$row04[thumbnail]\" border=\"0\" alt=\"".$row04['headline']."\"/></a>";
$hint .= "<div class=\"tb-kader-price\">".$pic_list_solo_final[$items03]['prijs']." €</div></span>";
$hint .= "</div>";
}
echo $hint;
?>
所以,最后
<a href=\"".$row04['link']></a>
应该在
中打开<div id="top"></div>
谢谢你们的努力!!
编辑
这个不工作:
$('#search').delegate(".fra", "click", function() {
$("#top").attr("src","href");
});
【问题讨论】:
-
新的 (v1.5) deferred objects 会有帮助吗?
-
如果您向我们展示您的代码(包括 html 和 jquery)会更容易提供帮助
-
你说得对,我更新了帖子
标签: php jquery ajax search-engine