Friday, 6 September 2013

AJAX Call Undefined

AJAX Call Undefined

I'm trying to make an AJAX call in Prestashop and I think I am missing
something. I tried reading all over StackOverflow but couldn't find any
answer to my problem.
In product-list.tpl I have this javascript in literal tags.
<script type="text/javascript">
$(document).ready(function() {
$(".ajaxquicklook").click(function() {
var id_product = $(this).attr('id_product');
//alert($(this).attr('id'));
$.ajax({
type: 'GET',
url: baseDir +'modules/quicklook/quicklook-ajax.php',
data: "id_product=" + id_product,
cache: 'false',
success: function(data)
{
alert("success!");
}
});
});
});
</script>
I have the a href call for ajaxquicklook class (along with the various
class for Fancybox).
<a class="ajaxquicklook various"
title="{$product.name|escape:'htmlall':'UTF-8'}"
>{$product.name|escape:'htmlall':'UTF-8'|truncate:26:'...':true}</a>
I believe I am passing the AJAX variable to the PHP bridge file I have..
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/quicklook.php');
$quicklook = $_GET['id_product'];
echo $quicklook->ajaxCall();
Next step once I get this is to use $this->context->smarty->assign() in
quicklook.php before fetching it in quicklook.tpl, but I can't get this
AJAX to work. My main concern is that id_product is not coming from the
right place, do I need to define that first within product-list.tpl?
Thanks so much in advance, I could really use some guidance.

No comments:

Post a Comment