Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a sample piece of code:</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;What&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $anchorList = ""; $rows = array( array( 'NAME' =&gt; 'me1' , 'PLAN' =&gt; 'thePlan1' ) , array( 'NAME' =&gt; 'me2' , 'PLAN' =&gt; 'thePlan2' ) ); $anchorList .= "&lt;div class=\"dist\"&gt;"; $anchorList .= "&lt;ul&gt;"; foreach ($rows as $row) { $anchorList .= "&lt;li&gt;"; $anchorList .= createAnchorTag($row['NAME'], $row['PLAN']); $anchorList .= "&lt;/li&gt;"; } $anchorList .= "&lt;/ul&gt;"; $anchorList .= "&lt;/div&gt;"; echo $anchorList; function createAnchorTag($name, $plan) { return "&lt;a href=\"devplan.php?search-n=" . $name . "&amp;" . rawurlencode($plan) . "\"" . "&gt;" . $plan . "&lt;/a&gt;"; } ?&gt; &lt;/body&gt; &lt;/html&gt; &lt;script type="text/javascript" src="../scripts/jquery-1.4.2.modified.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // Code to fill center panels with data urlquery = location.search; urlparts = urlquery.split('&amp;'); urlplan = urlparts[1]; $(document).ready(function() { $('.dist a').click(function() { $.ajax({ url: 'php/dpdetails.php?q=' + urlplan, success: function (data) { $('#Pinfo').html(data); } }); return false; }); }); &lt;/script&gt; </code></pre> <p>In your click function you need to <code>return false</code> in order to override the anchor tags wanting to redirect.</p> <p><strong>[EDIT]</strong></p> <p>I believe your actually looking to parse the <code>href</code> attribute of the anchor tag and pass it to the Ajax, right? If so use this script:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('.dist a').click(function() { var urlquery = $(this).attr('href').val(); // regex would be better than split, could create a more generic function var urlparts = urlquery.split('&amp;'); var urlplan = urlparts[1]; $.ajax({ url: 'php/dpdetails.php?q=' + urlplan, success: function (data) { $('#Pinfo').html(data); } }); return false; }); }); &lt;/script&gt; </code></pre>
 

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