asp.Netでjsとjqueryがashxを呼び出す異なる方法の共有

1360 ワード

=============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":,"count":"1","userID":'' }, function (data,statu) {
                if (statu == 'success') {
                   if(data=="false"){
                      alert(" ");
                   }
                   else{
                      window.location="gwc.aspx?uid="+'';
                   }
                }
            })