2016-12-03 45 views
0

我试着发送到我的模块prestashop插件。我收到一条消息“技术验证已被拒绝”。此消息包含Prestashop添加令牌到ajax文件

您需要将令牌添加到您的ajax文件。

我的AJAX脚本是:

$.ajax({ 
     type: "post", 
     url : "../modules/priceupdate/ajax-call.php", 
     data: "ajax=ps_ajax_update_prices", 
     success : function(response){ 
      $('#update-ajaxresponse').html(response) 
     } 
    }); 

问候

回答

2

通常令牌是由的PrestaShop声明,你应该在你的data只添加标记:

$.ajax({ 
    type: "post", 
    url : "../modules/priceupdate/ajax-call.php", 
    data: "ajax=ps_ajax_update_prices&token=" + token , 
    success : function(response){ 
     $('#update-ajaxresponse').html(response) 
    } 
}); 
+0

谢谢,我我需要在ajax-call.php中对令牌进行控制? – user5510975

+0

@ user5510975显然!这是为了防止CSRF攻击。服务器端可以使用Tools :: getToken(),因为此刻我不记得,请参阅该类中的规格。 – sarcom