1
<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> 

i think problem is here.Amount is not geting .url is not working.

index.php?dispatch=paysrk.paymod?amount

Question updates:- enter image description here

My requirements:

When i click the unsubscribe button status in the database change to "US" and change UNSUBSCRIBE button to SUBSCRIBE. A notification with unsubscription completed

sreechith srk
  • 146
  • 12

3 Answers3

1

i think your problem is in the url syntax.

the first parameter to pass to the url is after ? and all the other parameters should preceded with & so your GET url should be like this

index.php?dispatch=paysrk.paymod&amount

xmlhttp.open("GET", "index.php?dispatch=paysrk.paymod&amount="+str, true);
samehanwar
  • 3,280
  • 2
  • 23
  • 26
1

If your request is done from CS-Cart environment please try:

<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>
Hungryweb
  • 615
  • 6
  • 11
1

you do exactly like this. 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> 
utube
  • 23
  • 6