Note that there are some explanatory texts on larger screens.

plurals
  1. POajax-calls into an ajax-call
    primarykey
    data
    text
    <p>I've got this problem that I can't solve. Partly because I can't explain it with the right terms. I'm new to this so sorry for this clumsy question.</p> <p>Below you can see an overview of my goal. I want to search some stuff from a database (with ajax) and display the results in a div below the search. This I can get this to work. But now, I want to be able to click on a result and get it in a div on top of the page. I learned it is normal that ajax can not handle this sort of actions and it is not possible to run jquery or other ajax-calls into an ajax-call. I also read things about jquery live() to work around this problem. </p> <p>Still it is not clear to me how to make things work.</p> <p>Is it possible to put me on the right track? Are there tutorials I missed? </p> <p>thank you!</p> <h2>step one</h2> <pre><code>&lt;div id="top"&gt;here comes an image&lt;/div&gt; &lt;textfield&gt; for the ajax search string + a button &lt;/textfield&gt; &lt;div id="search"&gt;target of the ajax-search&lt;/div&gt; </code></pre> <h2>step two: after a search we get this</h2> <pre><code>&lt;div id="top"&gt;here comes an image&lt;/div&gt; &lt;textfield&gt; for the ajax search string + a button &lt;/textfield&gt; &lt;div id="search"&gt;result 01 with link to a php-file: a result 02 with link to a php-file: b ... &lt;/div&gt; </code></pre> <h2>step tree: after click on result 01 or 02 ...</h2> <pre><code>&lt;div id="top"&gt;content of php-file: a&lt;/div&gt; &lt;textfield&gt; for the ajax search string + a button &lt;/textfield&gt; &lt;div id="search"&gt;result 01 with link to a php-file: a result 02 with link to a php-file: b ... &lt;/div&gt; </code></pre> <p>ok, here comes part of the (relevant) code</p> <h2>search_page.php</h2> <pre><code>&lt;div id=top"&gt;&lt;/div&gt; &lt;div class="client_search_field"&gt; &lt;form id="ui_element" class="sb_wrapper" action="" method="post" name="search_ID" ONSubmit="xmlhttpPost('search_stream_client_v02.php', 'ui_element', 'txtHint', '&lt;img src=\'images/wait.gif\'&gt;'); return false;"&gt; &lt;p&gt; &lt;span class="sb_down"&gt;&lt;/span&gt; &lt;input name="search_string" type="text" class="sb_input" id="search_string" value="&lt;?php echo $_POST['search_string']; ?&gt;"/&gt; &lt;button type="submit" class="submitmag" id="search_submit" &gt; &lt;/button&gt; &lt;/p&gt; &lt;/div&gt; &lt;span id="txtHint"&gt;&lt;/span&gt; </code></pre> <h2>search_stream_client_v02.php</h2> <pre><code>&lt;?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 .= "&lt;div class=\"tb-kader\"&gt;"; $hint .= "&lt;span id=\"".$row['thumbnail']."\"&gt;"; $hint .= "&lt;a href=\"".$row04['link']."\" class=\"fra tooltip lazy\" id=\"".$row04['ID']."\" TITLE=\"header=[".$row04['headline']."] body=[".$row04['description']."]\"&gt;"; $hint .= "&lt;img src=\"$row04[thumbnail]\" border=\"0\" alt=\"".$row04['headline']."\"/&gt;&lt;/a&gt;"; $hint .= "&lt;div class=\"tb-kader-price\"&gt;".$pic_list_solo_final[$items03]['prijs']." &amp;euro;&lt;/div&gt;&lt;/span&gt;"; $hint .= "&lt;/div&gt;"; } echo $hint; ?&gt; </code></pre> <p>so, at the end the </p> <pre><code>&lt;a href=\"".$row04['link']&gt;&lt;/a&gt; </code></pre> <p>should open in the </p> <pre><code>&lt;div id="top"&gt;&lt;/div&gt; </code></pre> <p>thank you guys for your effort!!</p> <p>EDIT</p> <p>This one is not working:</p> <pre><code>$('#search').delegate(".fra", "click", function() { $("#top").attr("src","href"); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload