您的位置:首页 > Web前端 > JQuery

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

2013-06-07 00:00 686 查看
=============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%>';
                   }
                }
            })
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: