asp.net中js和jquery调用ashx的不同方法分享
时间:2021-02-17 14:03:23|栏目:.NET代码|点击: 次
=============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%>';
}
}
})
复制代码 代码如下:
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%>';
}
}
})
上一篇:C#中Predicate
栏 目:.NET代码
下一篇:WPF/Silverlight实现图片局部放大的方法分析
本文标题:asp.net中js和jquery调用ashx的不同方法分享
本文地址:http://www.codeinn.net/misctech/64617.html