Ajax and malsup cycle plugin
Hi
I'm new to all jquery, and this is the first time I have ever looked at Ajax... so probably a little out of my depth.
I have some Ajax here from a store I am working on. It duplicates product options and repears them underneath each other.
I am trying to get it to work so that it uses Malsup cycle plugin if more than one product option is chosen, it puts them in a cycle - but I need to to trigger the cycle plugin after the options have been selected.
This is the ajax (in javascript)
- <script type="text/javascript">
<!--
function build_product_options(qty) {
var same_opts = document.getElementById('same_options');
var http_location = "{$http_location}";
var request;
if (qty == 0)
qty = document.getElementById('product_avail_input').value;
$.ajax({
url: http_location + '/build_options.php?productid={$product.productid}&mode=build_opts&qty='+qty+'&same_opts=' + same_opts.checked,
type: 'GET',
dataType: 'json',
error: function(){
alert('AJAX request error');
},
success: function(data){
opmode = data.mode;
opqty = qty;
document.getElementById("build_options").innerHTML = data.html;
}
});
}
-->
</script>
And this is what I have so far for my jquery:
- $(function() {
$.ajaxSuccess(function($build_product_options) {
$('#build_options').cycle({
fx: 'scrollHorz',
timeout: 0,
pager: '#navi'
});
});
});
But as you probably already know, this isn't working :(
Should I be using ajaxsuccess or is there a simpler solution than this?