【问题标题】:how to use ajax in cscart如何在cs购物车中使用ajax
【发布时间】:2017-12-15 06:41:51
【问题描述】:
<script>
function showHint(str) {

    if (str.length == 0) {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("txtHint").innerHTML = this.responseText;
            }
        }
        xmlhttp.open("GET", "index.php?dispatch=paysrk.paymod?amount="+str, true);
        alert(+str);
        xmlhttp.send();
    }
}
</script> 

我认为问题就在这里。金额没有得到 .url 不起作用。

index.php?dispatch=paysrk.paymod?amount

问题更新:-

我的要求:

当我单击数据库中的取消订阅按钮状态更改为“美国”并将取消订阅按钮更改为订阅。取消订阅的通知已完成

【问题讨论】:

  • 你的 str 输出是什么?
  • 它只是文本框中的一个值。

标签: php ajax cs-cart


【解决方案1】:

如果您的请求是从 CS-Cart 环境完成的,请尝试:

<script>
function showHint(str){
    if (str.length == 0) {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else {
        $.ceAjax('request', fn_url('paysrk.paymod'), {
            method: 'get',
            caching: false,
            hidden:true,
            data: { 'amount': str },
            callback: function(data){
                alert(data);
            }
        });
    }
}
</script>

【讨论】:

  • 你能告诉我更多关于在cs购物车中使用ajax的信息吗?
  • 您可以使用 Tygh::$app['ajax']->assign('x', $x); 从 php 将值返回给 ajax 回调请让我知道您需要知道什么?
  • 我刚刚编辑了这个问题。感谢您的回复。
【解决方案2】:

我认为你的问题在于 url 语法。

传递给url的第一个参数在?之后,所有其他参数都应该在&amp;之前 所以你的GETurl应该是这样的

index.php?dispatch=paysrk.paymod&amount

xmlhttp.open("GET", "index.php?dispatch=paysrk.paymod&amount="+str, true);

【讨论】:

    【解决方案3】:

    你就是这样做的。 函数 showHint(str) {

        if (str.length == 0) {
            document.getElementById("txtHint").innerHTML = "";
            return;
        } else {
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = function() {
                if (this.readyState == 4 && this.status == 200) {
                    document.getElementById("txtHint").innerHTML = this.responseText;
                }
            }
            xmlhttp.open("GET", "index.php?dispatch=paysrk.paymod?amount="+str, true));
            alert(+str);
            xmlhttp.send();
        }
    }
    </script> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 2018-10-03
      相关资源
      最近更新 更多