I’m working on something where there are 2 links which triggers some Ajax. However I need to turn the links into Flash buttons (AS3). I’ve never worked with Ajax before, and I have no idea how this can be done.
Edit:
The Ajax:
<script>
$(document).ready(function() {
$('a.catlink').unbind('click').click(function(e)
{
e.preventDefault();
var link = $(this);
var inputs = [];
var cat_type = $(this).attr('href').replace('#', '');
link.attr('disabled', 'disabled');
inputs.push('cat_type=' + escape(cat_type));
$.ajax(
{
type: "POST",
cache: false,
dataType: "html",
url: window.location.href,
data: inputs.join('&'),
success: function(html)
{
var json = $.parseJSON(html);
if (json['status'] == 1)
{
$('div.listing').html(json['html']);
}
link.removeAttr('disabled');
}
});
});
});
</script>
The HTML
<h1 class="section-head">Products
// **The 2 links*** //
<a class="catlink" href="#cinema">cinema</a> <a class="catlink" href="#smart">smart</a></h1>
<div class="listing">
<ul class="listing">
{foreach from=$products item="product_info"}
<li class="clearfix">
<div class="inner-left">
<a href="{if $product_info.title_url}{$product_info.title_url}{else}{$product_info.url}{/if}"><img height="68" width="90" src="{$product_info.image}" /></a>
<h2 class="normal mt-5"><a href="{$product_info.url}">{if $product_info.price != '0'}${$product_info.price}{else}Click for price »{/if}</a></h2>
</div>
<div class="inner-right">
<h3 class="mb-0"><a href="{if $product_info.title_url}{$product_info.title_url}{else}{$product_info.url}{/if}">{$product_info.productName}</a></h3>
<p class="small mb-5"><span class="quiet">{$product_info.category}</span></p>
<p class="mb-15">{$product_info.description}</p>
<a class="button getprice" href="{$product_info.url}">Buy Now</a>
<br><br>
</div>
</li>
{/foreach}
</ul>
</div>
If you’re going to use AS3 then you can use
ExternalInterface.call()to call a JavaScript function on the page. Though, using Ajax may not be required if you’re using AS3 because you can make use of theURLLoaderclass to do the same thing (call a PHP script and decode a result).If you describe more accurately what you want to achieve then I shall provide some example code and clarify a little more.