如何使用flash按钮触发Ajax?

如何使用flash按钮触发Ajax?,ajax,actionscript-3,Ajax,Actionscript 3,我正在做的是有两个链接可以触发一些Ajax。然而,我需要把链接变成闪光按钮(AS3)。我以前从未使用过Ajax,我不知道如何做到这一点 编辑: Ajax: <script> $(document).ready(function() { $('a.catlink').unbind('click').click(function(e) { e.preventDefault();

我正在做的是有两个链接可以触发一些Ajax。然而,我需要把链接变成闪光按钮(AS3)。我以前从未使用过Ajax,我不知道如何做到这一点

编辑:

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>

$(文档).ready(函数(){
$('a.catlink')。解除绑定('click')。单击(函数(e)
{
e、 预防默认值();
var-link=$(这个);
var输入=[];
var cat_type=$(this.attr('href').replace('#','');
link.attr('disabled','disabled');
push('cat_type='+escape(cat_type));
$.ajax(
{
类型:“POST”,
cache:false,
数据类型:“html”,
url:window.location.href,
数据:inputs.join(“&”),
成功:函数(html)
{
var json=$.parseJSON(html);
如果(json['status']==1)
{
$('div.listing').html(json['html']);
}
link.removeAttr('disabled');
}
});
});
});
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 &raquo;{/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>
产品
//**两个链接***//
    {foreach from=$products item=“product_info”}
  • {$product\u info.category}

    {$product_info.description}



  • {/foreach}

如果要使用AS3,则可以使用
ExternalInterface.call()
调用页面上的JavaScript函数。不过,如果使用AS3,可能不需要使用Ajax,因为您可以使用
URLLoader
类来做同样的事情(调用PHP脚本并解码结果)


如果您能更准确地描述您想要实现的目标,那么我将提供一些示例代码,并进一步说明。

干杯,尽管我恐怕无法准确地理解您想用AS3做什么?哦,是的。因此,这里没有这两个链接(HTML中的第二行),而是刷新产品。我需要将它们替换为页面顶部的两个闪烁按钮。这更有意义吗?好吧,假设你知道如何将flash嵌入网页,你只需要创建一个按钮并使用ExternalInterface调用你的AJAX。