Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 禁用友好URL时,Prestashop AJAX不起作用_Jquery_Ajax_Prestashop_Prestashop 1.6 - Fatal编程技术网

Jquery 禁用友好URL时,Prestashop AJAX不起作用

Jquery 禁用友好URL时,Prestashop AJAX不起作用,jquery,ajax,prestashop,prestashop-1.6,Jquery,Ajax,Prestashop,Prestashop 1.6,我正在为prestashop开发一个自定义模块,其中有一些AJAX请求。当友好URL打开时,AJAX请求可以正常工作,但当它关闭时,会显示404错误。AJAX请求将发送到控制器文件 $.ajax({ url: "{$base_url|escape:'htmlall':'UTF-8'}module/mymodule/ShippingOptions", type: 'post', data: 'ajax=true&selectDate=' + selectDate ,

我正在为prestashop开发一个自定义模块,其中有一些AJAX请求。当友好URL打开时,AJAX请求可以正常工作,但当它关闭时,会显示404错误。AJAX请求将发送到控制器文件

$.ajax({
    url: "{$base_url|escape:'htmlall':'UTF-8'}module/mymodule/ShippingOptions",
    type: 'post',
    data: 'ajax=true&selectDate=' + selectDate ,
    success: function (data) {
    }
});
ShippingOptions
是控制器文件。 如何更改此URL以打开和关闭友好URL? 这是prestashop 1.6


谢谢,因为您的Ajax请求使用了友好的url语法。您应该使用以下内容获取url:

{$link->getModuleLink('mymodule', 'ShippingOptions')|escape:'html'}

对于ajax调用,您可以使用下面的代码,不管URL是否友好

$.ajax({
    url: baseUri,
    type: 'post',
    data: {
        ajax       : true,
        selectDate : selectDate,
        module     : 'myModule',
        fc         : 'module',
        controller : 'ShippingOptions'
    },
    success: function (data) {
    }
});

$link->getModuleLink
可以在view.tpl文件中调用它吗?是的,这是为了在.tpl文件中使用。您可以与官方模块进行比较,例如:bankwire\views\templates\front\payment\u execution.tpl这可以正常工作,但它使ajax url如下所示
http://urbit.dev/index.php?fc=module&模块=我的模块&;控制器=发货选项&;id_lang=1
是否有任何方法将
&
编码到&?如果您检查官方代码上的代码,它将生成&;而且不确定它是| escape:'html'还是来自getModuleLink,尚未测试。您还可以传递其他参数getModuleLink($module,$controller='default',array$params=array(),$ssl=null,$id\u lang=null,$id\u shop=null,$relative\u protocol=false)