asp.net中js和jquery調(diào)用ashx的不同方法分享
更新時間:2013年06月07日 11:21:31 作者:
asp.net中js和jquery調(diào)用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%>';
}
}
})
復(fù)制代碼 代碼如下:
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=====================
復(fù)制代碼 代碼如下:
$.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%>';
}
}
})
相關(guān)文章
asp.net代碼中修改web.config節(jié)點的具體方法
在有些情況下,要在代碼中讀取一種全局變量,把這種全局變量放在web.config是一種常見的手段。2013-06-06適用與firefox ASP.NET無刷新二級聯(lián)動下拉列表
適用與firefox ASP.NET無刷新二級聯(lián)動下拉列表...2007-08-08.NET 6開發(fā)TodoList應(yīng)用之實現(xiàn)查詢排序
這篇文章主要介紹了如何通過.NET 6實現(xiàn)查詢排序功能,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí).NET 6有一定的幫助,感興趣的同學(xué)可以了解一下2022-01-01.Net6集成IdentityServer4?+AspNetCore?Identity讀取數(shù)據(jù)表用戶且鑒權(quán)授權(quán)管理A
這篇文章主要介紹了.Net6集成IdentityServer4與AspNetCore?Identity讀取數(shù)據(jù)表用戶且鑒權(quán)授權(quán)管理API,IdentityServer4?實現(xiàn)鑒權(quán)、授權(quán),AspNetCore?Identity實現(xiàn)數(shù)據(jù)庫用戶管理表直接生成,下文詳情需要朋友可以參考一下2022-07-07區(qū)分ASP.NET中g(shù)et方法和post方法
我們都知道,get是從服務(wù)器上獲取數(shù)據(jù),post是向服務(wù)器上傳數(shù)據(jù)。本文主要介紹ASP.NET中g(shù)et方法和post方法的區(qū)別,需要的朋友可以參考下2015-10-10關(guān)于多對多關(guān)系表無法更新與插入的問題
這篇文章主要介紹了關(guān)于多對多關(guān)系表無法更新與插入的問題 的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-07-07白刃之戰(zhàn):PHP vs. ASP.NET(節(jié)選)-架構(gòu)比較
白刃之戰(zhàn):PHP vs. ASP.NET(節(jié)選)-架構(gòu)比較...2006-09-09