The different ways that js and jquery call ashx in ES0en.net share

  • 2020-06-07 04:25:02
  • OfStack

=============js================

var xhr = new XMLHttpRequest();
            xhr.open("get", 'Controls/gengCart.ashx?CartID=' + input + '&count=' + inp, true);
            xhr.setRequestHeader("If-Modified-Since", "0");
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var result = xhr.responseText;
                    var json = eval("(" + result + ")");
                    alert(js.name);
                }
            };
            xhr.send(null);

============jquery=====================

  $.post('Controls/Cart.ashx', { "productID":<%= GetID %>,"count":"1","userID":'<%= uid %>' }, function (data,statu) {
                if (statu == 'success') {
                   if(data=="false"){
                      alert(" Please log in before doing this ");
                   }
                   else{
                      window.location="gwc.aspx?uid="+'<%= uid%>';
                   }
                }
            }) 

Related articles: