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%>';
}
}
})
复制代码 代码如下:
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%>';
}
}
})
上一篇: 解读absolute与relative
下一篇: Android开发中多进程共享数据简析