开发者

How to trigger Ajax with flash buttons?

开发者 https://www.devze.com 2023-03-11 17:26 出处:网络
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

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 &raquo;{/if}</a></h2>
              </div>
              <开发者_Go百科;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 the URLLoader class 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消