asp.net中js和jquery調用ashx的不同方法分享
更新時間:2013年06月07日 11:21:31 作者:
asp.net中js和jquery調用ashx的不同方法分享,需要的朋友可以參考一下
=============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%>';
}
}
})
相關文章
VS2010、VS2008等項目的默認瀏覽器修改方法(圖文)
默認情況下,VS會使用操作系統(tǒng)的默認瀏覽器,但我在調試 ASP.NET 程序時更偏向于使用IE瀏覽器,下面與大家分享下VS2010、VS2008等項目的默認瀏覽器的修改方法2013-05-05
Web系統(tǒng)通過EXE文件實現讀取客戶電腦MAC等硬件信息且兼容非IE瀏覽器
我們在實際Web應用中,可能會遇到“需要限定特定的電腦或用戶才能使用系統(tǒng)”的問題。2014-08-08
IdentityServer4實現.Net Core API接口權限認證(快速入門)
這篇文章主要介紹了IdentityServer4實現.Net Core API接口權限認證,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-03-03

