欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp.net中js和jquery调用ashx的不同方法分享

程序员文章站 2024-04-03 12:33:10
=============js================复制代码 代码如下:var xhr = new xmlhttprequest();  &n...
=============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("请登录后再进行此操作");
                   }
                   else{
                      window.location="gwc.aspx?uid="+'<%= uid%>';
                   }
                }
            })